changeset 40648:da4478ca0e32

manifest: perform cheap checks before potentially allocating memory Differential Revision: https://phab.mercurial-scm.org/D5258
author Augie Fackler <augie@google.com>
date Mon, 12 Nov 2018 20:32:58 -0500
parents f27f8e9ef1e7
children c36175456350
files mercurial/cext/manifest.c
diffstat 1 files changed, 3 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/cext/manifest.c	Mon Nov 12 20:31:57 2018 -0500
+++ b/mercurial/cext/manifest.c	Mon Nov 12 20:32:58 2018 -0500
@@ -137,13 +137,13 @@
 			return MANIFEST_TOO_SHORT_LINE;
 		}
 		next++; /* advance past newline */
-		if (!realloc_if_full(self)) {
-			return MANIFEST_OOM; /* no memory */
-		}
 		if (prev && strcmp(prev, data) > -1) {
 			/* This data isn't sorted, so we have to abort. */
 			return MANIFEST_NOT_SORTED;
 		}
+		if (!realloc_if_full(self)) {
+			return MANIFEST_OOM; /* no memory */
+		}
 		l = self->lines + ((self->numlines)++);
 		l->start = data;
 		l->len = next - data;