[Python-checkins] python/dist/src/Objects stringobject.c,2.177,2.178

loewis@users.sourceforge.net loewis@users.sourceforge.net
Wed, 14 Aug 2002 01:22:53 -0700


Update of /cvsroot/python/python/dist/src/Objects
In directory usw-pr-cvs1:/tmp/cvs-serv10028/Objects

Modified Files:
	stringobject.c 
Log Message:
Check for trailing backslash. Fixes #593656.


Index: stringobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/stringobject.c,v
retrieving revision 2.177
retrieving revision 2.178
diff -C2 -d -r2.177 -r2.178
*** stringobject.c	14 Aug 2002 07:46:26 -0000	2.177
--- stringobject.c	14 Aug 2002 08:22:50 -0000	2.178
***************
*** 547,550 ****
--- 547,555 ----
  		}
  		s++;
+                 if (s==end) {
+ 			PyErr_SetString(PyExc_ValueError,
+ 					"Trailing \\ in string");
+ 			goto failed;
+ 		}
  		switch (*s++) {
  		/* XXX This assumes ASCII! */
***************
*** 595,602 ****
  			}
  			if (!errors || strcmp(errors, "strict") == 0) {
- 				Py_DECREF(v);
  				PyErr_SetString(PyExc_ValueError, 
  						"invalid \\x escape");
! 				return NULL;
  			}
  			if (strcmp(errors, "replace") == 0) {
--- 600,606 ----
  			}
  			if (!errors || strcmp(errors, "strict") == 0) {
  				PyErr_SetString(PyExc_ValueError, 
  						"invalid \\x escape");
! 				goto failed;
  			}
  			if (strcmp(errors, "replace") == 0) {
***************
*** 609,613 ****
  					     "unknown error handling code: %.400s",
  					     errors);
! 				return NULL;
  			}
  #ifndef Py_USING_UNICODE
--- 613,617 ----
  					     "unknown error handling code: %.400s",
  					     errors);
! 				goto failed;
  			}
  #ifndef Py_USING_UNICODE
***************
*** 616,624 ****
  		case 'N':
  			if (unicode) {
- 				Py_DECREF(v);
  				com_error(com, PyExc_ValueError,
  					  "Unicode escapes not legal "
  					  "when Unicode disabled");
! 				return NULL;
  			}
  #endif
--- 620,627 ----
  		case 'N':
  			if (unicode) {
  				com_error(com, PyExc_ValueError,
  					  "Unicode escapes not legal "
  					  "when Unicode disabled");
! 				goto failed;
  			}
  #endif