Patchwork D1904: bdiff: Handle the possibility of integer overflow when computing allocation size

login
register
mail settings
Submitter phabricator
Date Jan. 18, 2018, 7:58 p.m.
Message ID <5c5398bd862a84b238e140567990c0f1@localhost.localdomain>
Download mbox | patch
Permalink /patch/26928/
State Not Applicable
Headers show

Comments

phabricator - Jan. 18, 2018, 7:58 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGee3cadb495e6: bdiff: Handle the possibility of integer overflow when computing allocation size (authored by alex_gaynor, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D1904?vs=4904&id=4927

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

AFFECTED FILES
  mercurial/bdiff.c

CHANGE DETAILS




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

Patch

diff --git a/mercurial/bdiff.c b/mercurial/bdiff.c
--- a/mercurial/bdiff.c
+++ b/mercurial/bdiff.c
@@ -95,7 +95,7 @@ 
 
 	/* try to allocate a large hash table to avoid collisions */
 	for (scale = 4; scale; scale /= 2) {
-		h = (struct pos *)malloc(scale * buckets * sizeof(struct pos));
+		h = (struct pos *)calloc(buckets, scale * sizeof(struct pos));
 		if (h)
 			break;
 	}