Branch: Tag:

2016-12-16

2016-12-16 17:37:48 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Strings [`+]: Fixed handling of empty string.

Don't propagate the min range from the empty string when adding strings.

Code that triggered the bug:

string res = "";
foreach(a, string segment) {
res += segment + "/"; // Adds "" + segment + "/".
// res here got min set to 0 (kept from "").
// ...
}

This caused string_has_null() to return true for the above string res.

Fixes [bug 7826 (#7826)].

1895:    {    if(b->flags & STRING_CONTENT_CHECKED)    { +  if (a->len) {    if( b->min < a->min ) a->min = b->min;    if( b->max > a->max ) a->max = b->max; -  +  } else { +  a->min = b->min; +  a->max = b->max;    } -  +  }    else    a->flags &= ~STRING_CONTENT_CHECKED;    }