Visitar URL original
gh-101703: use `PyOS_snprintf` instead of `sprintf` by sobolevn · Pull Request #101729 · python/cpython · GitHub
Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Bisect errors to a single place
  • Loading branch information
sobolevn committed Feb 9, 2023
commit dff1e731ddad99c7b92ba60798050e8194adeced
3 changes: 1 addition & 2 deletions Objects/unicodeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -733,8 +733,7 @@ xmlcharrefreplace(_PyBytesWriter *writer, char *str,

/* generate replacement */
for (i = collstart; i < collend; ++i) {
size = PyOS_snprintf(str, 10 + 1, "&#%d;", // see `incr` above
PyUnicode_READ(kind, data, i));
size = sprintf(str, "&#%d;", PyUnicode_READ(kind, data, i));
if (size < 0) {
return NULL;
}
Expand Down
2 changes: 1 addition & 1 deletion Parser/string_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ decode_unicode_with_escapes(Parser *parser, const char *s, size_t len, Token *t)
w_len = PyUnicode_GET_LENGTH(w);
for (i = 0; i < w_len; i++) {
Py_UCS4 chr = PyUnicode_READ(kind, data, i);
PyOS_snprintf(p, 10 + 1, "\\U%08x", chr);
sprintf(p, "\\U%08x", chr);
p += 10;
}
/* Should be impossible to overflow */
Expand Down
3 changes: 1 addition & 2 deletions Python/pystrtod.c
Original file line number Diff line number Diff line change
Expand Up @@ -1239,8 +1239,7 @@ format_float_short(double d, char format_code,
/* Now that we've done zero padding, add an exponent if needed. */
if (use_exp) {
*p++ = float_strings[OFS_E][0];
/* See `bufsize` comments for the max size. */
exp_len = PyOS_snprintf(p, 5 + 1, "%+.02d", exp);
exp_len = sprintf(p, "%+.02d", exp);
p += exp_len;
}
exit:
Expand Down