]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Patch #1540329: _hotshot.c fix backports.
authorGeorg Brandl <georg@python.org>
Sat, 19 Aug 2006 07:48:06 +0000 (07:48 +0000)
committerGeorg Brandl <georg@python.org>
Sat, 19 Aug 2006 07:48:06 +0000 (07:48 +0000)
Modules/_hotshot.c

index 82fedccf879b20213e4083a273f4f6dddc08e6ea..cb9e207666a7760650703f2ab300aff15b56caf1 100644 (file)
@@ -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';