]> granicus.if.org Git - python/commitdiff
Fix possible crashes in pwdmodule.c. (GH-10331)
authorZackery Spytz <zspytz@gmail.com>
Mon, 5 Nov 2018 19:26:40 +0000 (12:26 -0700)
committerSerhiy Storchaka <storchaka@gmail.com>
Mon, 5 Nov 2018 19:26:40 +0000 (21:26 +0200)
"p" was not initialized if the first PyMem_RawRealloc() call failed.

Modules/pwdmodule.c

index 1286e7d5ce593b4020dda5356cd9a853f8555f74..fd11f848b2cef94575d30393a6b3b61e8dc819e2 100644 (file)
@@ -145,6 +145,7 @@ pwd_getpwuid(PyObject *module, PyObject *uidobj)
     while(1) {
         buf2 = PyMem_RawRealloc(buf, bufsize);
         if (buf2 == NULL) {
+            p = NULL;
             nomem = 1;
             break;
         }
@@ -227,6 +228,7 @@ pwd_getpwnam_impl(PyObject *module, PyObject *name)
     while(1) {
         buf2 = PyMem_RawRealloc(buf, bufsize);
         if (buf2 == NULL) {
+            p = NULL;
             nomem = 1;
             break;
         }