From c6be1cade08003e00588459991619cce75a81fe0 Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Sun, 2 Sep 2018 22:29:21 -0600 Subject: [PATCH 1/2] bpo-23855: Add missing NULL checks for malloc() in _msi.c --- .../next/Windows/2018-09-02-22-29-03.bpo-23855.mdTfXN.rst | 1 + PC/_msi.c | 7 +++++++ 2 files changed, 8 insertions(+) create mode 100644 Misc/NEWS.d/next/Windows/2018-09-02-22-29-03.bpo-23855.mdTfXN.rst diff --git a/Misc/NEWS.d/next/Windows/2018-09-02-22-29-03.bpo-23855.mdTfXN.rst b/Misc/NEWS.d/next/Windows/2018-09-02-22-29-03.bpo-23855.mdTfXN.rst new file mode 100644 index 00000000000000..07a995ab02b6e9 --- /dev/null +++ b/Misc/NEWS.d/next/Windows/2018-09-02-22-29-03.bpo-23855.mdTfXN.rst @@ -0,0 +1 @@ +Add missing ``NULL`` checks for ``malloc()`` in _msi.c. diff --git a/PC/_msi.c b/PC/_msi.c index 000d81f139f354..024b2d3c9fd301 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); } From 7a92bb00737f7ecae74410a9fdcabac5c4975f4c Mon Sep 17 00:00:00 2001 From: Berker Peksag Date: Sat, 8 Sep 2018 00:14:28 +0300 Subject: [PATCH 2/2] Delete 2018-09-02-22-29-03.bpo-23855.mdTfXN.rst --- .../NEWS.d/next/Windows/2018-09-02-22-29-03.bpo-23855.mdTfXN.rst | 1 - 1 file changed, 1 deletion(-) delete mode 100644 Misc/NEWS.d/next/Windows/2018-09-02-22-29-03.bpo-23855.mdTfXN.rst diff --git a/Misc/NEWS.d/next/Windows/2018-09-02-22-29-03.bpo-23855.mdTfXN.rst b/Misc/NEWS.d/next/Windows/2018-09-02-22-29-03.bpo-23855.mdTfXN.rst deleted file mode 100644 index 07a995ab02b6e9..00000000000000 --- a/Misc/NEWS.d/next/Windows/2018-09-02-22-29-03.bpo-23855.mdTfXN.rst +++ /dev/null @@ -1 +0,0 @@ -Add missing ``NULL`` checks for ``malloc()`` in _msi.c.