pike.git / src / builtin.cmod

version» Context lines:

pike.git/src/builtin.cmod:3114:       pop_n_elems(args);    res = fast_clone_object( Buffer_program );    str2 = OBJ2_BUFFER( res );    if (index < 0)    index = 0;    if (end >= len)    end = len-1;    str2->initial = end -= index-1;    init_string_builder_alloc (&str2->str, end, shift); -  memcpy (str2->str.s->str, (char*)p+(index<<shift), end<<shift); -  str2->str.s->len = end; +  memcpy ((s = str2->str.s)->str, (char*)p+(index<<shift), end<<shift); +  s->str[end<<shift] = 0; // Ensure NUL-termination +  s->len = end;    if( (Pike_fp->current_object->flags & OBJECT_CLEAR_ON_EXIT) )    res->flags |= OBJECT_CLEAR_ON_EXIT;    push_object (res);    }    }       /*! @decl int `[]=(int index, int ch)    */    PIKEFUN int `[]=(int index, int ch)    {
pike.git/src/builtin.cmod:3413:    end = len-1;       p = (char*)p+(index<<shift);    end -= index-1;    if (!vdiscard)    {    res = fast_clone_object( Buffer_program );    str2 = OBJ2_BUFFER( res );    init_string_builder_alloc(&str2->str, str2->initial = end, shift);    memcpy(str2->str.s->str, p, shift = end<<shift); +  str2->str.s->str[shift] = 0; // Ensure NUL-termination    str2->str.s->len = end;    } -  memmove(p, (char*)p+shift, shift); +  memmove(p, (char*)p+shift, shift+1); // Copy NUL-termination    s->len -= end;       if(!vdiscard)    {    if( (Pike_fp->current_object->flags & OBJECT_CLEAR_ON_EXIT) )    res->flags |= OBJECT_CLEAR_ON_EXIT;    push_object(res);    }    else    push_undefined();