diff options
author | Tzu-ping Chung <uranusjr@gmail.com> | 2019-02-02 17:13:23 (GMT) |
---|---|---|
committer | Steve Dower <steve.dower@microsoft.com> | 2019-02-02 17:13:23 (GMT) |
commit | 2de576e16d42ce43698d384d0dd46ba6cf165424 (patch) | |
tree | fc33745c8372fd578b3dbbdcdb35eec1fff77576 /PC/_msi.c | |
parent | 05e922136a3286893bd489a8f2ecfa0dba4da368 (diff) | |
download | cpython-2de576e16d42ce43698d384d0dd46ba6cf165424.zip cpython-2de576e16d42ce43698d384d0dd46ba6cf165424.tar.gz cpython-2de576e16d42ce43698d384d0dd46ba6cf165424.tar.bz2 |
bpo-1104: msilib.SummaryInfo.GetProperty() truncates the string by one character (GH-4517)
Add one char to MsiSummaryInfoGetProperty() output
Based on the patch in bpo-1104 by Anthony Tuininga (atuining) and Mark McMahon (markm).
Diffstat (limited to 'PC/_msi.c')
-rw-r--r-- | PC/_msi.c | 29 |
1 files changed, 19 insertions, 10 deletions
@@ -555,7 +555,7 @@ summary_getproperty(msiobj* si, PyObject *args) FILETIME fval; char sbuf[1000]; char *sval = sbuf; - DWORD ssize = sizeof(sval); + DWORD ssize = sizeof(sbuf); if (!PyArg_ParseTuple(args, "i:GetProperty", &field)) return NULL; @@ -563,6 +563,7 @@ summary_getproperty(msiobj* si, PyObject *args) status = MsiSummaryInfoGetProperty(si->h, field, &type, &ival, &fval, sval, &ssize); if (status == ERROR_MORE_DATA) { + ssize++; sval = malloc(ssize); if (sval == NULL) { return PyErr_NoMemory(); @@ -572,21 +573,29 @@ summary_getproperty(msiobj* si, PyObject *args) } switch(type) { - case VT_I2: case VT_I4: - return PyLong_FromLong(ival); + case VT_I2: + case VT_I4: + result = PyLong_FromLong(ival); + break; case VT_FILETIME: PyErr_SetString(PyExc_NotImplementedError, "FILETIME result"); - return NULL; + result = NULL; + break; case VT_LPSTR: result = PyBytes_FromStringAndSize(sval, ssize); - if (sval != sbuf) - free(sval); - return result; + break; case VT_EMPTY: - Py_RETURN_NONE; + Py_INCREF(Py_None); + result = Py_None; + break; + default: + PyErr_Format(PyExc_NotImplementedError, "result of type %d", type); + result = NULL; + break; } - PyErr_Format(PyExc_NotImplementedError, "result of type %d", type); - return NULL; + if (sval != sbuf) + free(sval); + return result; } static PyObject* |