]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-23855: Add missing NULL checks for malloc() in _msi.c (GH-9038)
authorZackery Spytz <zspytz@gmail.com>
Fri, 7 Sep 2018 22:02:56 +0000 (16:02 -0600)
committerBerker Peksag <berker.peksag@gmail.com>
Fri, 7 Sep 2018 22:02:56 +0000 (01:02 +0300)
PC/_msi.c

index 000d81f139f3541364043cbce19f9931adb602a6..024b2d3c9fd301ff5fcc26b45650b9c0cbc8ae83 100644 (file)
--- a/PC/_msi.c
+++ b/PC/_msi.c
@@ -330,6 +330,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';
     }
@@ -560,6 +564,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);
     }