[PATCH 1 of 5 stable cpychecker] diffhelpers: verify hline was created before using it
Augie Fackler
raf at durin42.com
Tue Jan 27 15:26:32 UTC 2015
# HG changeset patch
# User Augie Fackler <augie at google.com>
# Date 1422371224 18000
# Tue Jan 27 10:07:04 2015 -0500
# Branch stable
# Node ID 25af70176080cd54761b1624c900dc19252c9994
# Parent 0c4419faacbcca691737b5e25820dcbf4c7150ac
diffhelpers: verify hline was created before using it
Found with cpychecker.
diff --git a/mercurial/diffhelpers.c b/mercurial/diffhelpers.c
--- a/mercurial/diffhelpers.c
+++ b/mercurial/diffhelpers.c
@@ -34,6 +34,9 @@ static void _fix_newline(PyObject *hunk,
sz -= 1;
hline = PyBytes_FromStringAndSize(l, sz-1);
+ if (!hline) {
+ return NULL;
+ }
if (c == ' ' || c == '+') {
PyObject *rline = PyBytes_FromStringAndSize(l + 1, sz - 2);
@@ -194,4 +197,3 @@ initdiffhelpers(void)
NULL, NULL);
}
#endif
-
More information about the Mercurial-devel
mailing list