From 9be0b2e3122b8cb3078367e667bb6ab58cd81610 Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Sun, 12 Sep 2010 03:40:54 +0000 Subject: [PATCH] detect non-ascii characters much earlier (plugs ref leak) --- Objects/unicodeobject.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index c010b1b246..3b0a66ae74 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -764,6 +764,13 @@ PyUnicode_FromFormatV(const char *format, va_list vargs) if (*f == 's') ++callcount; } + else if (128 <= (unsigned char)*f) { + PyErr_Format(PyExc_ValueError, + "PyUnicode_FromFormatV() expects an ASCII-encoded format " + "string, got a non-ascii byte: 0x%02x", + (unsigned char)*f); + return NULL; + } } /* step 2: allocate memory for the results of * PyObject_Str()/PyObject_Repr()/PyUnicode_DecodeUTF8() calls */ @@ -1103,13 +1110,6 @@ PyUnicode_FromFormatV(const char *format, va_list vargs) goto end; } } - else if (128 <= (unsigned char)*f) { - PyErr_Format(PyExc_ValueError, - "PyUnicode_FromFormatV() expects an ASCII-encoded format " - "string, got a non-ascii byte: 0x%02x", - (unsigned char)*f); - goto fail; - } else *s++ = *f; } -- 2.49.0