Commit f96ec53b authored by Benjamin Peterson's avatar Benjamin Peterson

detect non-ascii characters much earlier (plugs ref leak)

parent 05f7ba32
...@@ -764,6 +764,13 @@ PyUnicode_FromFormatV(const char *format, va_list vargs) ...@@ -764,6 +764,13 @@ PyUnicode_FromFormatV(const char *format, va_list vargs)
if (*f == 's') if (*f == 's')
++callcount; ++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 /* step 2: allocate memory for the results of
* PyObject_Str()/PyObject_Repr()/PyUnicode_DecodeUTF8() calls */ * PyObject_Str()/PyObject_Repr()/PyUnicode_DecodeUTF8() calls */
...@@ -1103,13 +1110,6 @@ PyUnicode_FromFormatV(const char *format, va_list vargs) ...@@ -1103,13 +1110,6 @@ PyUnicode_FromFormatV(const char *format, va_list vargs)
goto end; 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 else
*s++ = *f; *s++ = *f;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment