Skip to content
Snippets Groups Projects
Commit da4478ca0e32 authored by Augie Fackler's avatar Augie Fackler
Browse files

manifest: perform cheap checks before potentially allocating memory

Differential Revision: https://phab.mercurial-scm.org/D5258
parent f27f8e9ef1e7
No related branches found
No related tags found
No related merge requests found
......@@ -137,10 +137,7 @@
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;
}
......@@ -143,7 +140,10 @@
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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment