diff options
author | Takashi Iwai <tiwai@suse.de> | 2005-08-18 14:58:31 +0000 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2005-08-18 14:58:31 +0000 |
commit | 1fdd1a6c190e722d127c3d67b5d37faf9b45560b (patch) | |
tree | 0a8c882a9af35c9facbdf712f8feb81a01d991fe /src/conf.c | |
parent | e120114bde308ff361b55599be1432af9fefdc01 (diff) | |
download | alsa-lib-1fdd1a6c190e722d127c3d67b5d37faf9b45560b.tar.gz |
Fix invalid read in setlocale()
Fix suspicious warnings "Invalid read" of setlocale() detected by valgrind2.
Diffstat (limited to 'src/conf.c')
-rw-r--r-- | src/conf.c | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -499,16 +499,21 @@ static int safe_strtod(const char *str, double *val) char *end; double v; char *saved_locale; + char locstr[64]; /* enough? */ int err; if (!*str) return -EINVAL; saved_locale = setlocale(LC_NUMERIC, NULL); - setlocale(LC_NUMERIC, "C"); + if (saved_locale) { + snprintf(locstr, sizeof(locstr), "%s", saved_locale); + setlocale(LC_NUMERIC, "C"); + } errno = 0; v = strtod(str, &end); err = -errno; - setlocale(LC_NUMERIC, saved_locale); + if (saved_locale) + setlocale(LC_NUMERIC, locstr); if (err) return err; if (*end) @@ -993,7 +998,7 @@ static int parse_array_def(snd_config_t *father, input_t *input, int idx, int sk snd_config_t *n = NULL; if (!skip) { - char static_id[12]; + char static_id[12]; snprintf(static_id, sizeof(static_id), "%i", idx); id = strdup(static_id); if (id == NULL) |