mirror of
https://github.com/python/cpython.git
synced 2025-10-06 07:02:33 +00:00
[3.6] bpo-29714: Fix a regression that bytes format may fail when containing zero bytes inside. (GH-504)
This commit is contained in:
parent
4e1a065c20
commit
df6d7b406f
3 changed files with 15 additions and 2 deletions
|
@ -619,11 +619,11 @@ _PyBytes_FormatEx(const char *format, Py_ssize_t format_len,
|
|||
Py_ssize_t len;
|
||||
char *pos;
|
||||
|
||||
pos = strchr(fmt + 1, '%');
|
||||
pos = (char *)memchr(fmt + 1, '%', fmtcnt);
|
||||
if (pos != NULL)
|
||||
len = pos - fmt;
|
||||
else
|
||||
len = format_len - (fmt - format);
|
||||
len = fmtcnt + 1;
|
||||
assert(len != 0);
|
||||
|
||||
memcpy(res, fmt, len);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue