diff options
author | Tzu-ping Chung <uranusjr@gmail.com> | 2019-02-19 03:06:10 (GMT) |
---|---|---|
committer | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2019-02-19 03:06:10 (GMT) |
commit | d5409eb6c26c6bca2686762ce0fd5223bb845e8a (patch) | |
tree | bd369e7d5c215be0a88f83fac6b69926783467e7 /PC | |
parent | 49778ada0ea6b7d83f49a2a758fd6716a632dbca (diff) | |
download | cpython-d5409eb6c26c6bca2686762ce0fd5223bb845e8a.zip cpython-d5409eb6c26c6bca2686762ce0fd5223bb845e8a.tar.gz cpython-d5409eb6c26c6bca2686762ce0fd5223bb845e8a.tar.bz2 |
[2.7] bpo-1104: msilib.SummaryInfo.GetProperty() truncates the string by one character (GH-4517) (GH-11749)
Add one char to MsiSummaryInfoGetProperty() output
Based on the patch in [bpo-1104](https://bugs.python.org/issue1104) by Anthony Tuininga (atuining) and Mark McMahon (markm)
(cherry picked from commit 2de576e16d42ce43698d384d0dd46ba6cf165424)
Co-authored-by: Tzu-ping Chung <uranusjr@gmail.com>
https://bugs.python.org/issue1104
Diffstat (limited to 'PC')
-rw-r--r-- | PC/_msi.c | 31 |
1 files changed, 21 insertions, 10 deletions
@@ -539,7 +539,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; @@ -547,6 +547,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(); @@ -556,19 +557,29 @@ summary_getproperty(msiobj* si, PyObject *args) } switch(type) { - case VT_I2: case VT_I4: - return PyInt_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 = PyString_FromStringAndSize(sval, ssize); - if (sval != sbuf) - free(sval); - return result; + result = PyBytes_FromStringAndSize(sval, ssize); + break; + case VT_EMPTY: + 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* |