...
Code Block | ||||
---|---|---|---|---|
| ||||
#include <locale.h>
#include <stdlib.h>
#include <string.h>
void f2(void) {
const struct lconv *conv = localeconv();
struct lconv *copy_of_conv;
if (conv == NULL) {
/* Handle error */
}
copy_of_conv = (struct lconv *)malloc(sizeof(struct lconv));
if (copy_of_conv == NULL) {
/* Handle error */
}
memcpy(copy_of_conv, conv, sizeof(struct lconv));
if ('\0' == copy_of_conv->decimal_point[0]) {
copy_of_conv->decimal_point = ".";
}
/* ... */
} |
Risk Assessment
Modifying the object pointed to by the return value of these functions causes undefined behavior. Even if the modification succeeds, the modified object can be overwritten by a subsequent call to the getenv()
, setlocale()
, localeconv()
, or strerror()
functions.
...