To: vim_dev@googlegroups.com
Subject: Patch 7.4.063
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------

Patch 7.4.063
Problem:    Crash when using invalid key in Python dictionary.
Solution:   Check for object to be NULL.  Add tests. (ZyX)
Files:      src/if_py_both.h, src/testdir/test86.in, src/testdir/test86.ok,
            src/testdir/test87.in, src/testdir/test87.ok


*** ../vim-7.4.062/src/if_py_both.h	2013-07-24 17:09:19.000000000 +0200
--- src/if_py_both.h	2013-11-04 00:27:40.000000000 +0100
***************
*** 1624,1629 ****
--- 1624,1632 ----
      PyObject	*rObj = _DictionaryItem(self, keyObject, DICT_FLAG_RETURN_BOOL);
      int		ret;
  
+     if (rObj == NULL)
+ 	return -1;
+ 
      ret = (rObj == Py_True);
  
      Py_DECREF(rObj);
*** ../vim-7.4.062/src/testdir/test86.in	2013-07-13 14:00:31.000000000 +0200
--- src/testdir/test86.in	2013-11-04 00:27:11.000000000 +0100
***************
*** 1088,1093 ****
--- 1088,1096 ----
  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
*** ../vim-7.4.062/src/testdir/test86.ok	2013-06-23 16:38:39.000000000 +0200
--- src/testdir/test86.ok	2013-11-04 00:27:11.000000000 +0100
***************
*** 516,521 ****
--- 516,524 ----
  <<< 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
*** ../vim-7.4.062/src/testdir/test87.in	2013-07-06 13:41:30.000000000 +0200
--- src/testdir/test87.in	2013-11-04 00:27:11.000000000 +0100
***************
*** 1039,1044 ****
--- 1039,1047 ----
  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
*** ../vim-7.4.062/src/testdir/test87.ok	2013-06-23 16:38:39.000000000 +0200
--- src/testdir/test87.ok	2013-11-04 00:27:11.000000000 +0100
***************
*** 505,510 ****
--- 505,513 ----
  <<< 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
*** ../vim-7.4.062/src/version.c	2013-11-03 20:26:27.000000000 +0100
--- src/version.c	2013-11-04 00:26:39.000000000 +0100
***************
*** 740,741 ****
--- 740,743 ----
  {   /* Add new patch number below this line */
+ /**/
+     63,
  /**/

-- 
A parent can be arrested if his child cannot hold back a burp during a church
service.
		[real standing law in Nebraska, United States of America]

 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///
