bdiff: handle the possibility of an integer overflow when allocating
authorAlex Gaynor <agaynor@mozilla.com>
Wed, 17 Jan 2018 21:36:18 +0000
changeset 35677 cf2e2a7399bc
parent 35676 9c575c22dcf4
child 35678 43154a76f392
bdiff: handle the possibility of an integer overflow when allocating Differential Revision: https://phab.mercurial-scm.org/D1877
mercurial/bdiff.c
--- a/mercurial/bdiff.c	Tue Jan 16 08:40:14 2018 -0500
+++ b/mercurial/bdiff.c	Wed Jan 17 21:36:18 2018 +0000
@@ -41,7 +41,7 @@
 	if (p == plast)
 		i++;
 
-	*lr = l = (struct bdiff_line *)malloc(sizeof(struct bdiff_line) * i);
+	*lr = l = (struct bdiff_line *)calloc(i, sizeof(struct bdiff_line));
 	if (!l)
 		return -1;