]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-23855: Add missing NULL checks for malloc() in _msi.c (GH-9038)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Mon, 10 Sep 2018 16:41:31 +0000 (09:41 -0700)
committerGitHub <noreply@github.com>
Mon, 10 Sep 2018 16:41:31 +0000 (09:41 -0700)
(cherry picked from commit 4e519377b1b84c9414a360961276993d24198825)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
PC/_msi.c

index a7c8fa3d092a6437a1d0c760c7b503c548ca226b..0487743b59aaacd2980b64ab455279bbd3f77c8f 100644 (file)
--- a/PC/_msi.c
+++ b/PC/_msi.c
@@ -340,6 +340,10 @@ msierror(int status)
     code = MsiRecordGetInteger(err, 1); /* XXX code */
     if (MsiFormatRecord(0, err, res, &size) == ERROR_MORE_DATA) {
         res = malloc(size+1);
+        if (res == NULL) {
+            MsiCloseHandle(err);
+            return PyErr_NoMemory();
+        }
         MsiFormatRecord(0, err, res, &size);
         res[size]='\0';
     }
@@ -563,6 +567,9 @@ summary_getproperty(msiobj* si, PyObject *args)
         &fval, sval, &ssize);
     if (status == ERROR_MORE_DATA) {
         sval = malloc(ssize);
+        if (sval == NULL) {
+            return PyErr_NoMemory();
+        }
         status = MsiSummaryInfoGetProperty(si->h, field, &type, &ival,
             &fval, sval, &ssize);
     }