Skip to content

Commit f51a466

Browse files
bpo-23855: Add missing NULL checks for malloc() in _msi.c (GH-9038)
(cherry picked from commit 4e51937) Co-authored-by: Zackery Spytz <[email protected]>
1 parent bf2bd8f commit f51a466

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

PC/_msi.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,10 @@ msierror(int status)
321321
code = MsiRecordGetInteger(err, 1); /* XXX code */
322322
if (MsiFormatRecord(0, err, res, &size) == ERROR_MORE_DATA) {
323323
res = malloc(size+1);
324+
if (res == NULL) {
325+
MsiCloseHandle(err);
326+
return PyErr_NoMemory();
327+
}
324328
MsiFormatRecord(0, err, res, &size);
325329
res[size]='\0';
326330
}
@@ -544,6 +548,9 @@ summary_getproperty(msiobj* si, PyObject *args)
544548
&fval, sval, &ssize);
545549
if (status == ERROR_MORE_DATA) {
546550
sval = malloc(ssize);
551+
if (sval == NULL) {
552+
return PyErr_NoMemory();
553+
}
547554
status = MsiSummaryInfoGetProperty(si->h, field, &type, &ival,
548555
&fval, sval, &ssize);
549556
}

0 commit comments

Comments
 (0)