mirror of
https://github.com/vim/vim.git
synced 2025-09-25 03:54:15 -04:00
updated for version 7.3.658
Problem: NUL bytes truncate strings when converted from Python. Solution: Handle truncation as an error. (ZyX)
This commit is contained in:
@@ -2530,8 +2530,10 @@ _ConvertFromPyObject(PyObject *obj, typval_T *tv, PyObject *lookupDict)
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
else if (PyBytes_Check(obj))
|
||||
{
|
||||
char_u *result = (char_u *) PyBytes_AsString(obj);
|
||||
char_u *result;
|
||||
|
||||
if (PyString_AsStringAndSize(obj, (char **) &result, NULL) == -1)
|
||||
return -1;
|
||||
if (result == NULL)
|
||||
return -1;
|
||||
|
||||
@@ -2549,7 +2551,8 @@ _ConvertFromPyObject(PyObject *obj, typval_T *tv, PyObject *lookupDict)
|
||||
if (bytes == NULL)
|
||||
return -1;
|
||||
|
||||
result = (char_u *) PyBytes_AsString(bytes);
|
||||
if(PyString_AsStringAndSize(bytes, (char **) &result, NULL) == -1)
|
||||
return -1;
|
||||
if (result == NULL)
|
||||
return -1;
|
||||
|
||||
@@ -2572,7 +2575,8 @@ _ConvertFromPyObject(PyObject *obj, typval_T *tv, PyObject *lookupDict)
|
||||
if (bytes == NULL)
|
||||
return -1;
|
||||
|
||||
result=(char_u *) PyString_AsString(bytes);
|
||||
if(PyString_AsStringAndSize(bytes, (char **) &result, NULL) == -1)
|
||||
return -1;
|
||||
if (result == NULL)
|
||||
return -1;
|
||||
|
||||
@@ -2587,8 +2591,10 @@ _ConvertFromPyObject(PyObject *obj, typval_T *tv, PyObject *lookupDict)
|
||||
}
|
||||
else if (PyString_Check(obj))
|
||||
{
|
||||
char_u *result = (char_u *) PyString_AsString(obj);
|
||||
char_u *result;
|
||||
|
||||
if(PyString_AsStringAndSize(obj, (char **) &result, NULL) == -1)
|
||||
return -1;
|
||||
if (result == NULL)
|
||||
return -1;
|
||||
|
||||
|
Reference in New Issue
Block a user