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