1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-04 17:47:26 +03:00

fix bug 289; make sure to reset the offset into a string when reallocating space

(This used to be commit 66dd20c7eaa66abdf99fa57475ccc4c9f978f1b5)
This commit is contained in:
Gerald Carter 2003-08-25 20:42:24 +00:00
parent a1d6ba950b
commit 6153bc0f5b

View File

@ -910,6 +910,7 @@ char *realloc_string_sub(char *string, const char *pattern, const char *insert)
while ((p = strstr(s,pattern))) {
if (ld > 0) {
int offset = PTR_DIFF(s,string);
char *t = Realloc(string, ls + ld + 1);
if (!t) {
DEBUG(0, ("realloc_string_sub: out of memory!\n"));
@ -917,7 +918,7 @@ char *realloc_string_sub(char *string, const char *pattern, const char *insert)
return NULL;
}
string = t;
p = t + (p - s);
p = t + offset + (p - s);
}
if (li != lp) {
memmove(p+li,p+lp,strlen(p+lp)+1);