# HG changeset patch # User Augie Fackler # Date 1542072778 18000 # Node ID da4478ca0e3242d3a74eb0e0038ff83be30691f4 # Parent f27f8e9ef1e731723146b670a1a9a86e1a088069 manifest: perform cheap checks before potentially allocating memory Differential Revision: https://phab.mercurial-scm.org/D5258 diff -r f27f8e9ef1e7 -r da4478ca0e32 mercurial/cext/manifest.c --- 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;