diff options
author | Brian Curtin <brian.curtin@gmail.com> | 2010-08-17 20:08:40 (GMT) |
---|---|---|
committer | Brian Curtin <brian.curtin@gmail.com> | 2010-08-17 20:08:40 (GMT) |
commit | abb3351785f0e526a8f5170a5ad08ae9d4638a0a (patch) | |
tree | 1d44d9e38b4af5337f1030d0e5666817a11b38c6 /PC/winreg.c | |
parent | 19467d27ff14ebe31978438078ed5a661ffd29fb (diff) | |
download | cpython-abb3351785f0e526a8f5170a5ad08ae9d4638a0a.zip cpython-abb3351785f0e526a8f5170a5ad08ae9d4638a0a.tar.gz cpython-abb3351785f0e526a8f5170a5ad08ae9d4638a0a.tar.bz2 |
Properly downcast from size_t/Py_ssize_t in a few places.
Diffstat (limited to 'PC/winreg.c')
-rw-r--r-- | PC/winreg.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/PC/winreg.c b/PC/winreg.c index eacb4c2..390a9ce 100644 --- a/PC/winreg.c +++ b/PC/winreg.c @@ -765,8 +765,9 @@ Py2Reg(PyObject *value, DWORD typ, BYTE **retDataBuf, DWORD *retDataSize) else { if (!PyUnicode_Check(value)) return FALSE; - - *retDataSize = 2 + PyUnicode_GET_DATA_SIZE(value); + *retDataSize = Py_SAFE_DOWNCAST( + 2 + PyUnicode_GET_DATA_SIZE(value), + size_t, DWORD); } *retDataBuf = (BYTE *)PyMem_NEW(DWORD, *retDataSize); if (*retDataBuf==NULL){ @@ -798,7 +799,8 @@ Py2Reg(PyObject *value, DWORD typ, BYTE **retDataBuf, DWORD *retDataSize) t = PyList_GET_ITEM(value, j); if (!PyUnicode_Check(t)) return FALSE; - size += 2 + PyUnicode_GET_DATA_SIZE(t); + size += Py_SAFE_DOWNCAST(2 + PyUnicode_GET_DATA_SIZE(t), + size_t, DWORD); } *retDataSize = size + 2; @@ -848,7 +850,7 @@ Py2Reg(PyObject *value, DWORD typ, BYTE **retDataBuf, DWORD *retDataSize) PyErr_NoMemory(); return FALSE; } - *retDataSize = view.len; + *retDataSize = Py_SAFE_DOWNCAST(view.len, Py_ssize_t, DWORD); memcpy(*retDataBuf, view.buf, view.len); PyBuffer_Release(&view); } |