Skip to content

Commit

Permalink
updated for version 7.4.063
Browse files Browse the repository at this point in the history
Problem:    Crash when using invalid key in Python dictionary.
Solution:   Check for object to be NULL.  Add tests. (ZyX)
  • Loading branch information
brammool committed Nov 3, 2013
1 parent d5d015d commit ba2d7ff
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/if_py_both.h
Original file line number Diff line number Diff line change
Expand Up @@ -1624,6 +1624,9 @@ DictionaryContains(DictionaryObject *self, PyObject *keyObject)
PyObject *rObj = _DictionaryItem(self, keyObject, DICT_FLAG_RETURN_BOOL);
int ret;

if (rObj == NULL)
return -1;

ret = (rObj == Py_True);

Py_DECREF(rObj);
Expand Down
3 changes: 3 additions & 0 deletions src/testdir/test86.in
Original file line number Diff line number Diff line change
Expand Up @@ -1088,6 +1088,9 @@ ee('d.get("a", 2, 3)')
stringtochars_test('d.get(%s)')
ee('d.pop("a")')
ee('dl.pop("a")')
cb.append(">> DictionaryContains")
ee('"" in d')
ee('0 in d')
cb.append(">> DictionaryIterNext")
ee('for i in ned: ned["a"] = 1')
del i
Expand Down
3 changes: 3 additions & 0 deletions src/testdir/test86.ok
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,9 @@ d.get("\0"):TypeError:('expected string without null bytes',)
<<< Finished
d.pop("a"):KeyError:('a',)
dl.pop("a"):error:('dictionary is locked',)
>> DictionaryContains
"" in d:ValueError:('empty keys are not allowed',)
0 in d:TypeError:('expected str() or unicode() instance, but got int',)
>> DictionaryIterNext
for i in ned: ned["a"] = 1:RuntimeError:('hashtab changed during iteration',)
>> DictionaryAssItem
Expand Down
3 changes: 3 additions & 0 deletions src/testdir/test87.in
Original file line number Diff line number Diff line change
Expand Up @@ -1039,6 +1039,9 @@ ee('d.get("a", 2, 3)')
stringtochars_test('d.get(%s)')
ee('d.pop("a")')
ee('dl.pop("a")')
cb.append(">> DictionaryContains")
ee('"" in d')
ee('0 in d')
cb.append(">> DictionaryIterNext")
ee('for i in ned: ned["a"] = 1')
del i
Expand Down
3 changes: 3 additions & 0 deletions src/testdir/test87.ok
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,9 @@ d.get("\0"):(<class 'TypeError'>, TypeError('expected bytes with no null',))
<<< Finished
d.pop("a"):(<class 'KeyError'>, KeyError('a',))
dl.pop("a"):(<class 'vim.error'>, error('dictionary is locked',))
>> DictionaryContains
"" in d:(<class 'ValueError'>, ValueError('empty keys are not allowed',))
0 in d:(<class 'TypeError'>, TypeError('expected bytes() or str() instance, but got int',))
>> DictionaryIterNext
for i in ned: ned["a"] = 1:(<class 'RuntimeError'>, RuntimeError('hashtab changed during iteration',))
>> DictionaryAssItem
Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
63,
/**/
62,
/**/
Expand Down

0 comments on commit ba2d7ff

Please sign in to comment.