[Python-checkins] bpo-23855: Add missing NULL checks for malloc() in _msi.c (GH-9038)

Berker Peksag webhook-mailer at python.org
Fri Sep 7 18:02:59 EDT 2018


https://github.com/python/cpython/commit/4e519377b1b84c9414a360961276993d24198825
commit: 4e519377b1b84c9414a360961276993d24198825
branch: master
author: Zackery Spytz <zspytz at gmail.com>
committer: Berker Peksag <berker.peksag at gmail.com>
date: 2018-09-08T01:02:56+03:00
summary:

bpo-23855: Add missing NULL checks for malloc() in _msi.c (GH-9038)

files:
M PC/_msi.c

diff --git a/PC/_msi.c b/PC/_msi.c
index 000d81f139f3..024b2d3c9fd3 100644
--- 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);
     }



More information about the Python-checkins mailing list