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

(cherry picked from commit 4e519377b1)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
This commit is contained in:
Miss Islington (bot) 2018-09-10 09:41:12 -07:00 committed by GitHub
parent bf2bd8f8a1
commit f51a46631f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 0 deletions

View File

@ -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);
}