Skip to content

Commit

Permalink
bpo-23855: Add missing NULL checks for malloc() in _msi.c (GH-9038)
Browse files Browse the repository at this point in the history
(cherry picked from commit 4e51937)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
  • Loading branch information
miss-islington and ZackerySpytz committed Sep 10, 2018
1 parent bf2bd8f commit f51a466
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions PC/_msi.c
Expand Up @@ -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';
}
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit f51a466

Please sign in to comment.