Mercurial > cpython-lru_cache-weakref
diff Python/exceptions.c @ 21072:639c0a3ae8dc legacy-trunk
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.
| author | Jeremy Hylton <jeremy@alum.mit.edu> |
|---|---|
| date | Wed, 28 Nov 2001 20:24:33 +0000 |
| parents | 8b3ea7335c1b |
| children | d4406fbfcb4e |
line wrap: on
line diff
--- a/Python/exceptions.c Wed Nov 28 19:41:45 2001 +0000 +++ b/Python/exceptions.c Wed Nov 28 20:24:33 2001 +0000 @@ -810,21 +810,21 @@ 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)", - PyString_AS_STRING(str), - my_basename(PyString_AS_STRING(filename)), - PyInt_AsLong(lineno)); + 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)", - PyString_AS_STRING(str), - my_basename(PyString_AS_STRING(filename))); + 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)", - PyString_AS_STRING(str), - PyInt_AsLong(lineno)); + PyOS_snprintf(buffer, bufsize, "%s (line %ld)", + PyString_AS_STRING(str), + PyInt_AsLong(lineno)); result = PyString_FromString(buffer); PyMem_FREE(buffer);
