Skip to content

Commit 4e51937

Browse files
ZackerySpytzberkerpeksag
authored andcommitted
bpo-23855: Add missing NULL checks for malloc() in _msi.c (GH-9038)
1 parent 2865848 commit 4e51937

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
@@ -330,6 +330,10 @@ msierror(int status)
330330
code = MsiRecordGetInteger(err, 1); /* XXX code */
331331
if (MsiFormatRecord(0, err, res, &size) == ERROR_MORE_DATA) {
332332
res = malloc(size+1);
333+
if (res == NULL) {
334+
MsiCloseHandle(err);
335+
return PyErr_NoMemory();
336+
}
333337
MsiFormatRecord(0, err, res, &size);
334338
res[size]='\0';
335339
}
@@ -560,6 +564,9 @@ summary_getproperty(msiobj* si, PyObject *args)
560564
&fval, sval, &ssize);
561565
if (status == ERROR_MORE_DATA) {
562566
sval = malloc(ssize);
567+
if (sval == NULL) {
568+
return PyErr_NoMemory();
569+
}
563570
status = MsiSummaryInfoGetProperty(si->h, field, &type, &ival,
564571
&fval, sval, &ssize);
565572
}

0 commit comments

Comments
 (0)