# HG changeset patch # User Augie Fackler <augie@google.com> # Date 2015-01-27 15:07:04 # Node ID c8e7fa41bfc53dc23fad0e977eb56a110370fccb # Parent df463ca0adefbf6ffa084cfd8031dcfc6c944f8e 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 -