ash: fix a SEGV in ${#1}
No binary (build failed)
—
(log yok)
| @@ -6746,6 +6746,14 @@ varvalue(char *name, int varflags, int flags, struct strlist *var_str_list) | |
| len = strlen(p); | |
| if (!(subtype == VSPLUS || subtype == VSLENGTH)) | |
| memtodest(p, len, syntax, quotes); | |
| + | #if ENABLE_UNICODE_SUPPORT |
| + | if (subtype == VSLENGTH && len > 0) { |
| + | reinit_unicode_for_ash(); |
| + | if (unicode_status == UNICODE_ON) { |
| + | len = unicode_strlen(p); |
| + | } |
| + | } |
| + | #endif |
| return len; | |
| } | |
| @@ -6829,15 +6837,7 @@ evalvar(char *p, int flags, struct strlist *var_str_list) | |
| varunset(p, var, 0, 0); | |
| if (subtype == VSLENGTH) { | |
| - | ssize_t n = varlen; |
| - | if (n > 0) { |
| - | reinit_unicode_for_ash(); |
| - | if (unicode_status == UNICODE_ON) { |
| - | const char *val = lookupvar(var); |
| - | n = unicode_strlen(val); |
| - | } |
| - | } |
| - | cvtnum(n > 0 ? n : 0); |
| + | cvtnum(varlen > 0 ? varlen : 0); |
| goto record; | |
| } | |