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:
parent
18d7dff1bb
commit
7399407725
|
@ -330,6 +330,10 @@ msierror(int status)
|
||||||
code = MsiRecordGetInteger(err, 1); /* XXX code */
|
code = MsiRecordGetInteger(err, 1); /* XXX code */
|
||||||
if (MsiFormatRecord(0, err, res, &size) == ERROR_MORE_DATA) {
|
if (MsiFormatRecord(0, err, res, &size) == ERROR_MORE_DATA) {
|
||||||
res = malloc(size+1);
|
res = malloc(size+1);
|
||||||
|
if (res == NULL) {
|
||||||
|
MsiCloseHandle(err);
|
||||||
|
return PyErr_NoMemory();
|
||||||
|
}
|
||||||
MsiFormatRecord(0, err, res, &size);
|
MsiFormatRecord(0, err, res, &size);
|
||||||
res[size]='\0';
|
res[size]='\0';
|
||||||
}
|
}
|
||||||
|
@ -560,6 +564,9 @@ summary_getproperty(msiobj* si, PyObject *args)
|
||||||
&fval, sval, &ssize);
|
&fval, sval, &ssize);
|
||||||
if (status == ERROR_MORE_DATA) {
|
if (status == ERROR_MORE_DATA) {
|
||||||
sval = malloc(ssize);
|
sval = malloc(ssize);
|
||||||
|
if (sval == NULL) {
|
||||||
|
return PyErr_NoMemory();
|
||||||
|
}
|
||||||
status = MsiSummaryInfoGetProperty(si->h, field, &type, &ival,
|
status = MsiSummaryInfoGetProperty(si->h, field, &type, &ival,
|
||||||
&fval, sval, &ssize);
|
&fval, sval, &ssize);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue