comparison mercurial/diffhelpers.c @ 23959:c8e7fa41bfc5 stable

diffhelpers: verify hline was created before using it Found with cpychecker.
author Augie Fackler <augie@google.com>
date Tue, 27 Jan 2015 10:07:04 -0500
parents 0a0933d3d59c
children f1c127df7c4f
comparison
equal deleted inserted replaced
23958:df463ca0adef 23959:c8e7fa41bfc5
32 if (sz > 1 && l[sz-2] == '\r') 32 if (sz > 1 && l[sz-2] == '\r')
33 /* tolerate CRLF in last line */ 33 /* tolerate CRLF in last line */
34 sz -= 1; 34 sz -= 1;
35 35
36 hline = PyBytes_FromStringAndSize(l, sz-1); 36 hline = PyBytes_FromStringAndSize(l, sz-1);
37 if (!hline) {
38 return NULL;
39 }
37 40
38 if (c == ' ' || c == '+') { 41 if (c == ' ' || c == '+') {
39 PyObject *rline = PyBytes_FromStringAndSize(l + 1, sz - 2); 42 PyObject *rline = PyBytes_FromStringAndSize(l + 1, sz - 2);
40 PyList_SetItem(b, blen-1, rline); 43 PyList_SetItem(b, blen-1, rline);
41 } 44 }
192 Py_InitModule3("diffhelpers", methods, diffhelpers_doc); 195 Py_InitModule3("diffhelpers", methods, diffhelpers_doc);
193 diffhelpers_Error = PyErr_NewException("diffhelpers.diffhelpersError", 196 diffhelpers_Error = PyErr_NewException("diffhelpers.diffhelpersError",
194 NULL, NULL); 197 NULL, NULL);
195 } 198 }
196 #endif 199 #endif
197