Skip to content
Myr

Fix stb_arr_insertn and stb_arr_deleten memmove lengths

Before adoption: this commit came in with the history the project adopted, so no landing records it.

They were moving memory beyond the array bounds.

authored by blackpawn · committed by blackpawn · parent 64fa9a3 · Browse files · 1 file+2 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+2 added−2 removed

  • other:+2 added−2 removed

1 file+2 added−2 removed

modified:stb.h+2 added-2 removed
3247 unmodified lines
3248 }32493250 z = stb_arr_len2(p);3251 stb__arr_addlen_(&p, size, i STB__ARGS);3252 memmove((char *) p + (i+n)*size, (char *) p + i*size, size * (z-i));3252 memmove((char *) p + (i+n)*size, (char *) p + i*size, size * (z-(i+n)));3253 }3254 *pp = p;3255}32563257void stb__arr_deleten_(void **pp, int size, int i, int n STB__PARAMS)3258{3259 void *p = *pp;3260 if (n) {3261 memmove((char *) p + i*size, (char *) p + (i+n)*size, size * (stb_arr_len2(p)-i));3261 memmove((char *) p + i*size, (char *) p + (i+n)*size, size * (stb_arr_len2(p)-(i+n)));3262 stb_arrhead2(p)->len -= n;3263 }3264 *pp = p;3265}
10871 unmodified lines