pike.git / src / stralloc.c

version» Context lines:

pike.git/src/stralloc.c:797:    s = internal_findstring(str,len,shift,h);       if (!s) {    s = make_static_string(str, len, shift);    link_pike_string(s, h);    } else {    if (!string_is_static(s)) {    if (string_is_block_allocated(s)) {    ba_free(&string_allocator, s->str);    } else if(string_is_substring(s)) { -  if( ((struct substring_pike_string *)s)->parent ) +  if( ((struct substring_pike_string *)s)->parent ) {    free_string( ((struct substring_pike_string *)s)->parent ); -  +  ((struct substring_pike_string *)s)->parent = NULL; +  }    s->str = (char*)str; -  +  /* NOTE: We MUST NOT change the alloc_type, since that +  * would associate s with the wrong block allocator, +  * and cause a crash when s is eventually freed. +  */ +  goto done;    }    else    {    free(s->str);    }    s->alloc_type = STRING_ALLOC_STATIC;    s->str = (char*)str;    } -  +  done:    add_ref(s);    }       return s;   }      /*    * This function assumes that the shift size is already the minimum it    * can be.    */