|
|
|
|
|
by kazinator
812 days ago
|
|
snprintf only returns negative if an "encoding error" occurs, which has to do with multi-byte characters. I think for that to possibly happen, you have to be in a locale with some character encoding in effect and snprintf is asked to print some multi-byte sequence that is invalid for that encoding. Thus, I suspect, if you don't call that "f...f...frob my C program" function known as setlocale, it will never happen. |
|
Of all the footguns in a hosted C implementation, I believe setlocale (and locale in general) is so broken that even compilers and library developers can't workaround it to make it safe.
The only other unfixable C-standard footgun that comes close, I think, are the environment-reading-and-writing functions, but at least with those, worst-case is leaking a negligible amount of memory in normal usage, or using an old value even when a newer one is available.