changeset 35677:cf2e2a7399bc

bdiff: handle the possibility of an integer overflow when allocating Differential Revision: https://phab.mercurial-scm.org/D1877
author Alex Gaynor <agaynor@mozilla.com>
date Wed, 17 Jan 2018 21:36:18 +0000
parents 9c575c22dcf4
children 43154a76f392
files mercurial/bdiff.c
diffstat 1 files changed, 1 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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;