Patchwork D1877: bdiff: Handle the possibility of an integer overflow when allocating

login
register
mail settings
Submitter phabricator
Date Jan. 17, 2018, 10:09 p.m.
Message ID <6669b65922fff2cf95d23898455e2425@localhost.localdomain>
Download mbox | patch
Permalink /patch/26832/
State Not Applicable
Headers show

Comments

phabricator - Jan. 17, 2018, 10:09 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGcf2e2a7399bc: bdiff: handle the possibility of an integer overflow when allocating (authored by alex_gaynor, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D1877?vs=4858&id=4862

REVISION DETAIL
  https://phab.mercurial-scm.org/D1877

AFFECTED FILES
  mercurial/bdiff.c

CHANGE DETAILS




To: alex_gaynor, #hg-reviewers, durin42
Cc: indygreg, durin42, mercurial-devel

Patch

diff --git a/mercurial/bdiff.c b/mercurial/bdiff.c
--- a/mercurial/bdiff.c
+++ b/mercurial/bdiff.c
@@ -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;