Karsten Hopp 99c6df
To: vim_dev@googlegroups.com
Karsten Hopp 99c6df
Subject: Patch 7.3.1064
Karsten Hopp 99c6df
Fcc: outbox
Karsten Hopp 99c6df
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 99c6df
Mime-Version: 1.0
Karsten Hopp 99c6df
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 99c6df
Content-Transfer-Encoding: 8bit
Karsten Hopp 99c6df
------------
Karsten Hopp 99c6df
Karsten Hopp 99c6df
Patch 7.3.1064
Karsten Hopp 99c6df
Problem:    Python: insufficient error checking.
Karsten Hopp 99c6df
Solution:   Python patch 23. (ZyX)
Karsten Hopp 99c6df
Files:      src/if_py_both.h
Karsten Hopp 99c6df
Karsten Hopp 99c6df
Karsten Hopp 99c6df
*** ../vim-7.3.1063/src/if_py_both.h	2013-05-30 13:14:06.000000000 +0200
Karsten Hopp 99c6df
--- src/if_py_both.h	2013-05-30 13:16:23.000000000 +0200
Karsten Hopp 99c6df
***************
Karsten Hopp 99c6df
*** 3304,3313 ****
Karsten Hopp 99c6df
  
Karsten Hopp 99c6df
  	for (i = 0; i < new_len; ++i)
Karsten Hopp 99c6df
  	{
Karsten Hopp 99c6df
! 	    PyObject *line = PyList_GetItem(list, i);
Karsten Hopp 99c6df
  
Karsten Hopp 99c6df
! 	    array[i] = StringToLine(line);
Karsten Hopp 99c6df
! 	    if (array[i] == NULL)
Karsten Hopp 99c6df
  	    {
Karsten Hopp 99c6df
  		while (i)
Karsten Hopp 99c6df
  		    vim_free(array[--i]);
Karsten Hopp 99c6df
--- 3304,3313 ----
Karsten Hopp 99c6df
  
Karsten Hopp 99c6df
  	for (i = 0; i < new_len; ++i)
Karsten Hopp 99c6df
  	{
Karsten Hopp 99c6df
! 	    PyObject *line;
Karsten Hopp 99c6df
  
Karsten Hopp 99c6df
! 	    if (!(line = PyList_GetItem(list, i)) ||
Karsten Hopp 99c6df
! 		!(array[i] = StringToLine(line)))
Karsten Hopp 99c6df
  	    {
Karsten Hopp 99c6df
  		while (i)
Karsten Hopp 99c6df
  		    vim_free(array[--i]);
Karsten Hopp 99c6df
***************
Karsten Hopp 99c6df
*** 3319,3325 ****
Karsten Hopp 99c6df
  	VimTryStart();
Karsten Hopp 99c6df
  	PyErr_Clear();
Karsten Hopp 99c6df
  
Karsten Hopp 99c6df
! 	// START of region without "return".  Must call restore_buffer()!
Karsten Hopp 99c6df
  	switch_buffer(&savebuf, buf);
Karsten Hopp 99c6df
  
Karsten Hopp 99c6df
  	if (u_save((linenr_T)(lo-1), (linenr_T)hi) == FAIL)
Karsten Hopp 99c6df
--- 3319,3325 ----
Karsten Hopp 99c6df
  	VimTryStart();
Karsten Hopp 99c6df
  	PyErr_Clear();
Karsten Hopp 99c6df
  
Karsten Hopp 99c6df
! 	/* START of region without "return".  Must call restore_buffer()! */
Karsten Hopp 99c6df
  	switch_buffer(&savebuf, buf);
Karsten Hopp 99c6df
  
Karsten Hopp 99c6df
  	if (u_save((linenr_T)(lo-1), (linenr_T)hi) == FAIL)
Karsten Hopp 99c6df
***************
Karsten Hopp 99c6df
*** 3400,3406 ****
Karsten Hopp 99c6df
  	if (buf == savebuf)
Karsten Hopp 99c6df
  	    py_fix_cursor((linenr_T)lo, (linenr_T)hi, (linenr_T)extra);
Karsten Hopp 99c6df
  
Karsten Hopp 99c6df
! 	// END of region without "return".
Karsten Hopp 99c6df
  	restore_buffer(savebuf);
Karsten Hopp 99c6df
  
Karsten Hopp 99c6df
  	if (VimTryEnd())
Karsten Hopp 99c6df
--- 3400,3406 ----
Karsten Hopp 99c6df
  	if (buf == savebuf)
Karsten Hopp 99c6df
  	    py_fix_cursor((linenr_T)lo, (linenr_T)hi, (linenr_T)extra);
Karsten Hopp 99c6df
  
Karsten Hopp 99c6df
! 	/* END of region without "return". */
Karsten Hopp 99c6df
  	restore_buffer(savebuf);
Karsten Hopp 99c6df
  
Karsten Hopp 99c6df
  	if (VimTryEnd())
Karsten Hopp 99c6df
***************
Karsten Hopp 99c6df
*** 3479,3488 ****
Karsten Hopp 99c6df
  
Karsten Hopp 99c6df
  	for (i = 0; i < size; ++i)
Karsten Hopp 99c6df
  	{
Karsten Hopp 99c6df
! 	    PyObject *line = PyList_GetItem(lines, i);
Karsten Hopp 99c6df
! 	    array[i] = StringToLine(line);
Karsten Hopp 99c6df
  
Karsten Hopp 99c6df
! 	    if (array[i] == NULL)
Karsten Hopp 99c6df
  	    {
Karsten Hopp 99c6df
  		while (i)
Karsten Hopp 99c6df
  		    vim_free(array[--i]);
Karsten Hopp 99c6df
--- 3479,3488 ----
Karsten Hopp 99c6df
  
Karsten Hopp 99c6df
  	for (i = 0; i < size; ++i)
Karsten Hopp 99c6df
  	{
Karsten Hopp 99c6df
! 	    PyObject *line;
Karsten Hopp 99c6df
  
Karsten Hopp 99c6df
! 	    if (!(line = PyList_GetItem(lines, i)) ||
Karsten Hopp 99c6df
! 		!(array[i] = StringToLine(line)))
Karsten Hopp 99c6df
  	    {
Karsten Hopp 99c6df
  		while (i)
Karsten Hopp 99c6df
  		    vim_free(array[--i]);
Karsten Hopp 99c6df
***************
Karsten Hopp 99c6df
*** 4014,4021 ****
Karsten Hopp 99c6df
  
Karsten Hopp 99c6df
      if (!PyArg_ParseTuple(args, "s", &pmark))
Karsten Hopp 99c6df
  	return NULL;
Karsten Hopp 99c6df
-     mark = *pmark;
Karsten Hopp 99c6df
  
Karsten Hopp 99c6df
      VimTryStart();
Karsten Hopp 99c6df
      switch_buffer(&savebuf, self->buf);
Karsten Hopp 99c6df
      posp = getmark(mark, FALSE);
Karsten Hopp 99c6df
--- 4014,4028 ----
Karsten Hopp 99c6df
  
Karsten Hopp 99c6df
      if (!PyArg_ParseTuple(args, "s", &pmark))
Karsten Hopp 99c6df
  	return NULL;
Karsten Hopp 99c6df
  
Karsten Hopp 99c6df
+     if (STRLEN(pmark) != 1)
Karsten Hopp 99c6df
+     {
Karsten Hopp 99c6df
+ 	PyErr_SetString(PyExc_ValueError,
Karsten Hopp 99c6df
+ 		_("mark name must be a single character"));
Karsten Hopp 99c6df
+ 	return NULL;
Karsten Hopp 99c6df
+     }
Karsten Hopp 99c6df
+ 
Karsten Hopp 99c6df
+     mark = *pmark;
Karsten Hopp 99c6df
      VimTryStart();
Karsten Hopp 99c6df
      switch_buffer(&savebuf, self->buf);
Karsten Hopp 99c6df
      posp = getmark(mark, FALSE);
Karsten Hopp 99c6df
***************
Karsten Hopp 99c6df
*** 4258,4264 ****
Karsten Hopp 99c6df
  
Karsten Hopp 99c6df
  	if (value->ob_type != &BufferType)
Karsten Hopp 99c6df
  	{
Karsten Hopp 99c6df
! 	    PyErr_SetString(PyExc_TypeError, _("expected vim.buffer object"));
Karsten Hopp 99c6df
  	    return -1;
Karsten Hopp 99c6df
  	}
Karsten Hopp 99c6df
  
Karsten Hopp 99c6df
--- 4265,4271 ----
Karsten Hopp 99c6df
  
Karsten Hopp 99c6df
  	if (value->ob_type != &BufferType)
Karsten Hopp 99c6df
  	{
Karsten Hopp 99c6df
! 	    PyErr_SetString(PyExc_TypeError, _("expected vim.Buffer object"));
Karsten Hopp 99c6df
  	    return -1;
Karsten Hopp 99c6df
  	}
Karsten Hopp 99c6df
  
Karsten Hopp 99c6df
***************
Karsten Hopp 99c6df
*** 4283,4289 ****
Karsten Hopp 99c6df
  
Karsten Hopp 99c6df
  	if (value->ob_type != &WindowType)
Karsten Hopp 99c6df
  	{
Karsten Hopp 99c6df
! 	    PyErr_SetString(PyExc_TypeError, _("expected vim.window object"));
Karsten Hopp 99c6df
  	    return -1;
Karsten Hopp 99c6df
  	}
Karsten Hopp 99c6df
  
Karsten Hopp 99c6df
--- 4290,4296 ----
Karsten Hopp 99c6df
  
Karsten Hopp 99c6df
  	if (value->ob_type != &WindowType)
Karsten Hopp 99c6df
  	{
Karsten Hopp 99c6df
! 	    PyErr_SetString(PyExc_TypeError, _("expected vim.Window object"));
Karsten Hopp 99c6df
  	    return -1;
Karsten Hopp 99c6df
  	}
Karsten Hopp 99c6df
  
Karsten Hopp 99c6df
***************
Karsten Hopp 99c6df
*** 4315,4321 ****
Karsten Hopp 99c6df
      {
Karsten Hopp 99c6df
  	if (value->ob_type != &TabPageType)
Karsten Hopp 99c6df
  	{
Karsten Hopp 99c6df
! 	    PyErr_SetString(PyExc_TypeError, _("expected vim.tabpage object"));
Karsten Hopp 99c6df
  	    return -1;
Karsten Hopp 99c6df
  	}
Karsten Hopp 99c6df
  
Karsten Hopp 99c6df
--- 4322,4328 ----
Karsten Hopp 99c6df
      {
Karsten Hopp 99c6df
  	if (value->ob_type != &TabPageType)
Karsten Hopp 99c6df
  	{
Karsten Hopp 99c6df
! 	    PyErr_SetString(PyExc_TypeError, _("expected vim.TabPage object"));
Karsten Hopp 99c6df
  	    return -1;
Karsten Hopp 99c6df
  	}
Karsten Hopp 99c6df
  
Karsten Hopp 99c6df
*** ../vim-7.3.1063/src/version.c	2013-05-30 13:14:06.000000000 +0200
Karsten Hopp 99c6df
--- src/version.c	2013-05-30 13:15:32.000000000 +0200
Karsten Hopp 99c6df
***************
Karsten Hopp 99c6df
*** 730,731 ****
Karsten Hopp 99c6df
--- 730,733 ----
Karsten Hopp 99c6df
  {   /* Add new patch number below this line */
Karsten Hopp 99c6df
+ /**/
Karsten Hopp 99c6df
+     1064,
Karsten Hopp 99c6df
  /**/
Karsten Hopp 99c6df
Karsten Hopp 99c6df
-- 
Karsten Hopp 99c6df
How To Keep A Healthy Level Of Insanity:
Karsten Hopp 99c6df
7. Finish all your sentences with "in accordance with the prophecy".
Karsten Hopp 99c6df
Karsten Hopp 99c6df
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 99c6df
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 99c6df
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp 99c6df
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///