From: Georg Brandl Date: Sat, 19 Aug 2006 07:48:06 +0000 (+0000) Subject: Patch #1540329: _hotshot.c fix backports. X-Git-Tag: v2.4.4c1~116 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d0bcffe17a8ed016c4de101c4372b827963285e9;p=thirdparty%2FPython%2Fcpython.git Patch #1540329: _hotshot.c fix backports. --- diff --git a/Modules/_hotshot.c b/Modules/_hotshot.c index 82fedccf879b..cb9e207666a7 100644 --- a/Modules/_hotshot.c +++ b/Modules/_hotshot.c @@ -308,7 +308,12 @@ unpack_string(LogReaderObject *self, PyObject **pvalue) if ((err = unpack_packed_int(self, &len, 0))) return err; - buf = malloc(len); + buf = (char *)malloc(len); + if (!buf) { + PyErr_NoMemory(); + return ERR_EXCEPTION; + } + for (i=0; i < len; i++) { ch = fgetc(self->logfp); buf[i] = ch; @@ -1398,11 +1403,11 @@ get_version_string(void) char *buffer; int i = 0; - while (*rev && !isdigit((int)*rev)) + while (*rev && !isdigit(Py_CHARMASK(*rev))) ++rev; while (rev[i] != ' ' && rev[i] != '\0') ++i; - buffer = malloc(i + 1); + buffer = (char *)malloc(i + 1); if (buffer != NULL) { memmove(buffer, rev, i); buffer[i] = '\0';