Commit 05bd787c authored by Jeremy Hylton's avatar Jeremy Hylton

Use PyOS_snprintf instead of sprintf.

Just being sure.  The old code looks like it was safe, but there's no
harm in double-checking.
parent a30eacf4
......@@ -810,19 +810,19 @@ SyntaxError__str__(PyObject *self, PyObject *args)
if (have_filename)
bufsize += PyString_GET_SIZE(filename);
buffer = PyMem_Malloc(bufsize);
buffer = PyMem_MALLOC(bufsize);
if (buffer != NULL) {
if (have_filename && have_lineno)
sprintf(buffer, "%s (%s, line %ld)",
PyOS_snprintf(buffer, bufsize, "%s (%s, line %ld)",
PyString_AS_STRING(str),
my_basename(PyString_AS_STRING(filename)),
PyInt_AsLong(lineno));
else if (have_filename)
sprintf(buffer, "%s (%s)",
PyOS_snprintf(buffer, bufsize, "%s (%s)",
PyString_AS_STRING(str),
my_basename(PyString_AS_STRING(filename)));
else if (have_lineno)
sprintf(buffer, "%s (line %ld)",
PyOS_snprintf(buffer, bufsize, "%s (line %ld)",
PyString_AS_STRING(str),
PyInt_AsLong(lineno));
......
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