Closed SamSandq closed 7 months ago
It's a very curious case. It doesn't crash in Windows/Linux, but in macOS does. The last 0
is not detected and a buffer overflow occurs. The only explanation I can find is how va_arg()
is interpreted on macOS. If we change the last parameter from 0
to (const char_t*)NULL
then no crash.
// Crash (only on macOS)
String *str = str_repl("const Product **pr;", "const", "", "*", "", " ", "", 0);
// No crash
String *str = str_repl("const Product **pr;", "const", "", "*", "", " ", "", (const char_t*)NULL);
I have updated the doc. Will be visible in next website update.
Updated documentation. Just change 0
by NULL
in last parameter
https://nappgui.com/en/core/string.html#f13
I had problems (bad access crash) with
str_repl
and tried your example from https://nappgui.com/en/core/string.html#f13String *str = str_repl("const Product **pr;", "const", "", "*", "", " ", "", 0);
and it crashes too. I'm using v1.4.1 - r4927, if it helps.
Please check.
ADDED:
If I exclude the last pair of strings, i.e.:
String *str = str_repl("const Product **pr;", "const", "", "*", "", 0);
then it does NOT crash!
ADDED2:
Some more testing revealed that the issue might be in the number of pairs; 2 pairs is OK, but 3 or more causes a crash.