core, pulse, modules: Fix undefined behavior with array subscript of invalid type

From the NetBSD manual:

     The first argument of these functions is of type int, but only a very
     restricted subset of values are actually valid.  The argument must either
     be the value of the macro EOF (which has a negative value), or must be a
     non-negative value within the range representable as unsigned char.
     Passing invalid values leads to undefined behavior.

     --  ctype(3)
This commit is contained in:
Kamil Rytarowski 2015-11-20 04:20:36 +01:00 committed by Arun Raghavan
parent 9dd77827ad
commit 93cccdee8d
5 changed files with 15 additions and 15 deletions

View file

@ -131,7 +131,7 @@ pa_modargs *pa_modargs_new(const char *args, const char* const* valid_keys) {
case WHITESPACE:
if (*p == '=')
goto fail;
else if (!isspace(*p)) {
else if (!isspace((unsigned char)*p)) {
key = p;
state = KEY;
key_len = 1;
@ -141,7 +141,7 @@ pa_modargs *pa_modargs_new(const char *args, const char* const* valid_keys) {
case KEY:
if (*p == '=')
state = VALUE_START;
else if (isspace(*p))
else if (isspace((unsigned char)*p))
goto fail;
else
key_len++;
@ -156,7 +156,7 @@ pa_modargs *pa_modargs_new(const char *args, const char* const* valid_keys) {
state = VALUE_DOUBLE_QUOTES;
value = p+1;
value_len = 0;
} else if (isspace(*p)) {
} else if (isspace((unsigned char)*p)) {
if (add_key_value(ma,
pa_xstrndup(key, key_len),
pa_xstrdup(""),
@ -175,7 +175,7 @@ pa_modargs *pa_modargs_new(const char *args, const char* const* valid_keys) {
break;
case VALUE_SIMPLE:
if (isspace(*p)) {
if (isspace((unsigned char)*p)) {
if (add_key_value(ma,
pa_xstrndup(key, key_len),
pa_xstrndup(value, value_len),