Patchwork D4028: revlog: remove side effect from failed nt_init()

login
register
mail settings
Submitter phabricator
Date Aug. 3, 2018, 1:44 p.m.
Message ID <7323b99689f87df684d51fa6d87655e4@localhost.localdomain>
Download mbox | patch
Permalink /patch/33147/
State Not Applicable
Headers show

Comments

phabricator - Aug. 3, 2018, 1:44 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGd814bbd22946: revlog: remove side effect from failed nt_init() (authored by martinvonz, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D4028?vs=9728&id=9822

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

AFFECTED FILES
  mercurial/cext/revlog.c

CHANGE DETAILS




To: martinvonz, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/mercurial/cext/revlog.c b/mercurial/cext/revlog.c
--- a/mercurial/cext/revlog.c
+++ b/mercurial/cext/revlog.c
@@ -1112,8 +1112,11 @@ 
 		self->ntrev = (int)index_length(self) - 1;
 		self->ntlookups = 1;
 		self->ntmisses = 0;
-		if (nt_insert(self, nullid, INT_MAX) == -1)
+		if (nt_insert(self, nullid, INT_MAX) == -1) {
+			free(self->nt);
+			self->nt = NULL;
 			return -1;
+		}
 	}
 	return 0;
 }