You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Modifiers 'j' and 'z' do not work properly on some architecture, because the arguments have a size different from that inferred by the library, which results in wrong data being read from the varargs list.
To Reproduce stb_sprintf(buff, "%ji %zi %ti", (intmax_t)-1, (ssize_t)2, (ptrdiff_t)-3);
taken from the test:
case 'j': ... sizeof(intmax_t)
case 'z': ... sizeof(size_t)
Since intmax_t is not available for this library (see the discussion here: #633), something else should be used, e.g. assume that it is always 8, or do this:
The proper handling was already suggested before (see #633 above), but since it was manually merged, also with the goal of minimizing dependencies, the wrong types were used.
The text was updated successfully, but these errors were encountered:
Describe the bug
Modifiers 'j' and 'z' do not work properly on some architecture, because the arguments have a size different from that inferred by the library, which results in wrong data being read from the varargs list.
To Reproduce
stb_sprintf(buff, "%ji %zi %ti", (intmax_t)-1, (ssize_t)2, (ptrdiff_t)-3);
taken from the test:
stb/tests/test_sprintf.c
Line 75 in beebb24
To be executed on a platform with:
e.g. a 32-bit architecture like ARM Cortex-M
Fix
This:
stb/stb_sprintf.h
Lines 543 to 551 in beebb24
should be changed to have:
Since
intmax_t
is not available for this library (see the discussion here: #633), something else should be used, e.g. assume that it is always 8, or do this:Related
#632
#633
The proper handling was already suggested before (see #633 above), but since it was manually merged, also with the goal of minimizing dependencies, the wrong types were used.
The text was updated successfully, but these errors were encountered: