Skip to content

Commit 8a0c254

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 afb25bc commit 8a0c254

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
@@ -340,6 +340,10 @@ msierror(int status)
340340
code = MsiRecordGetInteger(err, 1); /* XXX code */
341341
if (MsiFormatRecord(0, err, res, &size) == ERROR_MORE_DATA) {
342342
res = malloc(size+1);
343+
if (res == NULL) {
344+
MsiCloseHandle(err);
345+
return PyErr_NoMemory();
346+
}
343347
MsiFormatRecord(0, err, res, &size);
344348
res[size]='\0';
345349
}
@@ -563,6 +567,9 @@ summary_getproperty(msiobj* si, PyObject *args)
563567
&fval, sval, &ssize);
564568
if (status == ERROR_MORE_DATA) {
565569
sval = malloc(ssize);
570+
if (sval == NULL) {
571+
return PyErr_NoMemory();
572+
}
566573
status = MsiSummaryInfoGetProperty(si->h, field, &type, &ival,
567574
&fval, sval, &ssize);
568575
}

0 commit comments

Comments
 (0)