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

Miss Islington (bot) webhook-mailer at python.org
Mon Sep 10 12:41:16 EDT 2018


https://github.com/python/cpython/commit/f51a46631f8dcca596c08a934a766da9afe93c06
commit: f51a46631f8dcca596c08a934a766da9afe93c06
branch: 2.7
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2018-09-10T09:41:12-07:00
summary:

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

(cherry picked from commit 4e519377b1b84c9414a360961276993d24198825)

Co-authored-by: Zackery Spytz <zspytz at gmail.com>

files:
M PC/_msi.c

diff --git a/PC/_msi.c b/PC/_msi.c
index d7700f09c749..68c4e79e2945 100644
--- a/PC/_msi.c
+++ b/PC/_msi.c
@@ -321,6 +321,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';
     }
@@ -544,6 +548,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