Skip to content
Open
Changes from all commits
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
14 changes: 10 additions & 4 deletions Objects/unicodeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -961,10 +961,16 @@

/* generate replacement */
for (i = collstart; i < collend; ++i) {
size = sprintf(str, "&#%d;", PyUnicode_READ(kind, data, i));
if (size < 0) {
return NULL;
}
// Use snprintf() with a temporary buffer to not write the trailing
// NUL byte in the writer buffer.
Py_BUILD_ASSERT(_Py_MAX_UNICODE <= 0x10ffff);

Check warning on line 966 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Windows (free-threading) / Build and test (x64)

sizeof returns 0 [D:\a\cpython\cpython\PCbuild\_freeze_module.vcxproj]

Check failure on line 966 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Windows (free-threading) / Build and test (x64)

cannot allocate an array of constant size 0 [D:\a\cpython\cpython\PCbuild\_freeze_module.vcxproj]

Check failure on line 966 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Windows (free-threading) / Build and test (x64)

expected constant expression [D:\a\cpython\cpython\PCbuild\_freeze_module.vcxproj]

Check failure on line 966 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Windows (free-threading) / Build and test (x64)

'_Py_MAX_UNICODE': undeclared identifier [D:\a\cpython\cpython\PCbuild\_freeze_module.vcxproj]

Check failure on line 966 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Hypothesis tests on Ubuntu

‘_Py_MAX_UNICODE’ undeclared (first use in this function); did you mean ‘MAX_UNICODE’?

Check warning on line 966 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Windows / Build and test (x64)

sizeof returns 0 [D:\a\cpython\cpython\PCbuild\_freeze_module.vcxproj]

Check failure on line 966 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Windows / Build and test (x64)

cannot allocate an array of constant size 0 [D:\a\cpython\cpython\PCbuild\_freeze_module.vcxproj]

Check failure on line 966 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Windows / Build and test (x64)

expected constant expression [D:\a\cpython\cpython\PCbuild\_freeze_module.vcxproj]

Check failure on line 966 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Windows / Build and test (x64)

'_Py_MAX_UNICODE': undeclared identifier [D:\a\cpython\cpython\PCbuild\_freeze_module.vcxproj]

Check warning on line 966 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Windows / Build and test (arm64)

sizeof returns 0 [C:\a\cpython\cpython\PCbuild\_freeze_module.vcxproj]

Check failure on line 966 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Windows / Build and test (arm64)

cannot allocate an array of constant size 0 [C:\a\cpython\cpython\PCbuild\_freeze_module.vcxproj]

Check failure on line 966 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Windows / Build and test (arm64)

expected constant expression [C:\a\cpython\cpython\PCbuild\_freeze_module.vcxproj]

Check failure on line 966 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Windows / Build and test (arm64)

'_Py_MAX_UNICODE': undeclared identifier [C:\a\cpython\cpython\PCbuild\_freeze_module.vcxproj]

Check failure on line 966 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Ubuntu / build and test (ubuntu-24.04-arm)

‘_Py_MAX_UNICODE’ undeclared (first use in this function); did you mean ‘MAX_UNICODE’?

Check failure on line 966 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Cross build Linux

‘_Py_MAX_UNICODE’ undeclared (first use in this function); did you mean ‘MAX_UNICODE’?

Check warning on line 966 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Windows (free-threading) / Build and test (arm64)

sizeof returns 0 [C:\a\cpython\cpython\PCbuild\_freeze_module.vcxproj]

Check failure on line 966 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Windows (free-threading) / Build and test (arm64)

cannot allocate an array of constant size 0 [C:\a\cpython\cpython\PCbuild\_freeze_module.vcxproj]

Check failure on line 966 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Windows (free-threading) / Build and test (arm64)

expected constant expression [C:\a\cpython\cpython\PCbuild\_freeze_module.vcxproj]

Check failure on line 966 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Windows (free-threading) / Build and test (arm64)

'_Py_MAX_UNICODE': undeclared identifier [C:\a\cpython\cpython\PCbuild\_freeze_module.vcxproj]

Check failure on line 966 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Ubuntu (free-threading) / build and test (ubuntu-24.04-arm)

‘_Py_MAX_UNICODE’ undeclared (first use in this function); did you mean ‘MAX_UNICODE’?

Check failure on line 966 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Ubuntu / build and test (ubuntu-24.04)

‘_Py_MAX_UNICODE’ undeclared (first use in this function); did you mean ‘MAX_UNICODE’?

Check failure on line 966 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Address sanitizer (ubuntu-26.04)

‘_Py_MAX_UNICODE’ undeclared (first use in this function); did you mean ‘MAX_UNICODE’?

Check failure on line 966 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Ubuntu (free-threading) / build and test (ubuntu-24.04)

‘_Py_MAX_UNICODE’ undeclared (first use in this function); did you mean ‘MAX_UNICODE’?

Check failure on line 966 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Ubuntu (installed) / build, install and test

‘_Py_MAX_UNICODE’ undeclared (first use in this function); did you mean ‘MAX_UNICODE’?

Check failure on line 966 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Ubuntu (bolt) / build and test (ubuntu-24.04)

‘_Py_MAX_UNICODE’ undeclared (first use in this function); did you mean ‘MAX_UNICODE’?
// len('&#1114111;\0') is 11 bytes.
char buffer[11];
Py_UCS4 ch = PyUnicode_READ(kind, data, i);
size = snprintf(buffer, sizeof(buffer), "&#%d;", ch);
assert(4 <= size && (size_t)size <= (sizeof(buffer) - 1));

memcpy(str, buffer, size);
str += size;
}
return str;
Expand Down
Loading