dcaee6
To: vim_dev@googlegroups.com
dcaee6
Subject: Patch 7.4.063
dcaee6
Fcc: outbox
dcaee6
From: Bram Moolenaar <Bram@moolenaar.net>
dcaee6
Mime-Version: 1.0
dcaee6
Content-Type: text/plain; charset=UTF-8
dcaee6
Content-Transfer-Encoding: 8bit
dcaee6
------------
dcaee6
dcaee6
Patch 7.4.063
dcaee6
Problem:    Crash when using invalid key in Python dictionary.
dcaee6
Solution:   Check for object to be NULL.  Add tests. (ZyX)
dcaee6
Files:      src/if_py_both.h, src/testdir/test86.in, src/testdir/test86.ok,
dcaee6
            src/testdir/test87.in, src/testdir/test87.ok
dcaee6
dcaee6
dcaee6
*** ../vim-7.4.062/src/if_py_both.h	2013-07-24 17:09:19.000000000 +0200
dcaee6
--- src/if_py_both.h	2013-11-04 00:27:40.000000000 +0100
dcaee6
***************
dcaee6
*** 1624,1629 ****
dcaee6
--- 1624,1632 ----
dcaee6
      PyObject	*rObj = _DictionaryItem(self, keyObject, DICT_FLAG_RETURN_BOOL);
dcaee6
      int		ret;
dcaee6
  
dcaee6
+     if (rObj == NULL)
dcaee6
+ 	return -1;
dcaee6
+ 
dcaee6
      ret = (rObj == Py_True);
dcaee6
  
dcaee6
      Py_DECREF(rObj);
dcaee6
*** ../vim-7.4.062/src/testdir/test86.in	2013-07-13 14:00:31.000000000 +0200
dcaee6
--- src/testdir/test86.in	2013-11-04 00:27:11.000000000 +0100
dcaee6
***************
dcaee6
*** 1088,1093 ****
dcaee6
--- 1088,1096 ----
dcaee6
  stringtochars_test('d.get(%s)')
dcaee6
  ee('d.pop("a")')
dcaee6
  ee('dl.pop("a")')
dcaee6
+ cb.append(">> DictionaryContains")
dcaee6
+ ee('"" in d')
dcaee6
+ ee('0 in d')
dcaee6
  cb.append(">> DictionaryIterNext")
dcaee6
  ee('for i in ned: ned["a"] = 1')
dcaee6
  del i
dcaee6
*** ../vim-7.4.062/src/testdir/test86.ok	2013-06-23 16:38:39.000000000 +0200
dcaee6
--- src/testdir/test86.ok	2013-11-04 00:27:11.000000000 +0100
dcaee6
***************
dcaee6
*** 516,521 ****
dcaee6
--- 516,524 ----
dcaee6
  <<< Finished
dcaee6
  d.pop("a"):KeyError:('a',)
dcaee6
  dl.pop("a"):error:('dictionary is locked',)
dcaee6
+ >> DictionaryContains
dcaee6
+ "" in d:ValueError:('empty keys are not allowed',)
dcaee6
+ 0 in d:TypeError:('expected str() or unicode() instance, but got int',)
dcaee6
  >> DictionaryIterNext
dcaee6
  for i in ned: ned["a"] = 1:RuntimeError:('hashtab changed during iteration',)
dcaee6
  >> DictionaryAssItem
dcaee6
*** ../vim-7.4.062/src/testdir/test87.in	2013-07-06 13:41:30.000000000 +0200
dcaee6
--- src/testdir/test87.in	2013-11-04 00:27:11.000000000 +0100
dcaee6
***************
dcaee6
*** 1039,1044 ****
dcaee6
--- 1039,1047 ----
dcaee6
  stringtochars_test('d.get(%s)')
dcaee6
  ee('d.pop("a")')
dcaee6
  ee('dl.pop("a")')
dcaee6
+ cb.append(">> DictionaryContains")
dcaee6
+ ee('"" in d')
dcaee6
+ ee('0 in d')
dcaee6
  cb.append(">> DictionaryIterNext")
dcaee6
  ee('for i in ned: ned["a"] = 1')
dcaee6
  del i
dcaee6
*** ../vim-7.4.062/src/testdir/test87.ok	2013-06-23 16:38:39.000000000 +0200
dcaee6
--- src/testdir/test87.ok	2013-11-04 00:27:11.000000000 +0100
dcaee6
***************
dcaee6
*** 505,510 ****
dcaee6
--- 505,513 ----
dcaee6
  <<< Finished
dcaee6
  d.pop("a"):(<class 'KeyError'>, KeyError('a',))
dcaee6
  dl.pop("a"):(<class 'vim.error'>, error('dictionary is locked',))
dcaee6
+ >> DictionaryContains
dcaee6
+ "" in d:(<class 'ValueError'>, ValueError('empty keys are not allowed',))
dcaee6
+ 0 in d:(<class 'TypeError'>, TypeError('expected bytes() or str() instance, but got int',))
dcaee6
  >> DictionaryIterNext
dcaee6
  for i in ned: ned["a"] = 1:(<class 'RuntimeError'>, RuntimeError('hashtab changed during iteration',))
dcaee6
  >> DictionaryAssItem
dcaee6
*** ../vim-7.4.062/src/version.c	2013-11-03 20:26:27.000000000 +0100
dcaee6
--- src/version.c	2013-11-04 00:26:39.000000000 +0100
dcaee6
***************
dcaee6
*** 740,741 ****
dcaee6
--- 740,743 ----
dcaee6
  {   /* Add new patch number below this line */
dcaee6
+ /**/
dcaee6
+     63,
dcaee6
  /**/
dcaee6
dcaee6
-- 
dcaee6
A parent can be arrested if his child cannot hold back a burp during a church
dcaee6
service.
dcaee6
		[real standing law in Nebraska, United States of America]
dcaee6
dcaee6
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
dcaee6
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
dcaee6
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
dcaee6
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///