diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1999-01-18 09:08:52 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1999-01-18 09:08:52 +0000 |
commit | 41d0ebf4660c74a92bfd9484bd3659d5367d2d76 (patch) | |
tree | f046d437bf3c46562223d3639ff5401297e3cd62 /hash.c | |
parent | 9f72c385f295637f8c7b3ed7a159cb7cfa9752ef (diff) |
1.2.2 PR1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/v1_1r@366 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'hash.c')
-rw-r--r-- | hash.c | 22 |
1 files changed, 20 insertions, 2 deletions
@@ -963,6 +963,10 @@ env_keys() env = environ; while (*env) { char *s = strchr(*env, '='); + if (!s) { + env++; + continue; + } ary_push(ary, str_taint(str_new(*env, s-*env))); env++; } @@ -985,6 +989,10 @@ env_values() env = environ; while (*env) { char *s = strchr(*env, '='); + if (!s) { + env++; + continue; + } ary_push(ary, str_taint(str_new2(s+1))); env++; } @@ -1050,6 +1058,10 @@ env_to_a() env = environ; while (*env) { char *s = strchr(*env, '='); + if (!s) { + env++; + continue; + } ary_push(ary, assoc_new(str_taint(str_new(*env, s-*env)), str_taint(str_new2(s+1)))); env++; @@ -1095,13 +1107,19 @@ env_has_value(dmy, value) { char **env; VALUE ary; + int len; if (TYPE(value) != T_STRING) return FALSE; ary = ary_new(); env = environ; while (*env) { - char *s = strchr(*env, '=')+1; - int len = strlen(s); + char *s = strchr(*env, '='); + if (!s) { + env++; + continue; + } + s++; + len = strlen(s); if (strncmp(s, RSTRING(value)->ptr, len) == 0) return TRUE; env++; } |