diff options
author | Jeremy Hylton <jeremy@alum.mit.edu> | 2001-11-28 20:24:33 +0000 |
---|---|---|
committer | Jeremy Hylton <jeremy@alum.mit.edu> | 2001-11-28 20:24:33 +0000 |
commit | 9079b0f96f4bb939ef92dfe7612ef5ac7f6bb4df (patch) | |
tree | c15412d37a75efc082ed967d2a6ed435d330ffc3 /Python/exceptions.c | |
parent | 57a2abc77dfcc3b8088b4aca60c889abee60e51d (diff) | |
download | cpython-9079b0f96f4bb939ef92dfe7612ef5ac7f6bb4df.tar.gz |
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.
Diffstat (limited to 'Python/exceptions.c')
-rw-r--r-- | Python/exceptions.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/Python/exceptions.c b/Python/exceptions.c index 4d17529720..99002bf1ad 100644 --- a/Python/exceptions.c +++ b/Python/exceptions.c @@ -810,21 +810,21 @@ 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)", - 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); |