# HG changeset patch # User Jim Hague # Date 2012-02-03 23:27:17 # Node ID 8134ec8627e7d94e73c2d7d023aaa4d631de1f03 # Parent f11eee00c6523347b4c3eff694ddf542a19864f6 bdiff: fix malloc(0) issue in fixws() If fixws() is called on a zero-length string, malloc(0) is called and expected to return a pointer. Which it does on e.g. Linux. AIX returns NULL, which it is also legal, but the malloc() is then assumed to have failed. So ensure a valid pointer is always returned. diff --git a/mercurial/bdiff.c b/mercurial/bdiff.c --- a/mercurial/bdiff.c +++ b/mercurial/bdiff.c @@ -443,7 +443,7 @@ static PyObject *fixws(PyObject *self, P r = PyBytes_AsString(s); rlen = PyBytes_Size(s); - w = (char *)malloc(rlen); + w = (char *)malloc(rlen ? rlen : 1); if (!w) goto nomem;