diff Objects/stringlib/string_format.h @ 62168:26fac74ebab3 legacy-trunk

correctly overflow when indexes are too large
author Benjamin Peterson <benjamin@python.org>
date Mon, 07 Jun 2010 22:23:23 +0000
parents fd25030223b0
children b36cb4602e21
line wrap: on
line diff
--- a/Objects/stringlib/string_format.h	Mon Jun 07 22:00:18 2010 +0000
+++ b/Objects/stringlib/string_format.h	Mon Jun 07 22:23:23 2010 +0000
@@ -373,6 +373,8 @@
         if (_FieldNameIterator_item(self, name) == 0)
             return 0;
         *name_idx = get_integer(name);
+        if (*name_idx == -1 && PyErr_Occurred())
+            return 0;
         break;
     default:
         /* Invalid character follows ']' */
@@ -429,6 +431,8 @@
 
     /* see if "first" is an integer, in which case it's used as an index */
     *first_idx = get_integer(first);
+    if (*first_idx == -1 && PyErr_Occurred())
+        return 0;
 
     field_name_is_empty = first->ptr >= first->end;