From 6153bc0f5bbf67d17bcfd21c2e8581defbe3a84f Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 25 Aug 2003 20:42:24 +0000 Subject: fix bug 289; make sure to reset the offset into a string when reallocating space (This used to be commit 66dd20c7eaa66abdf99fa57475ccc4c9f978f1b5) --- source3/lib/util_str.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/lib/util_str.c b/source3/lib/util_str.c index eb1c70d412..c356fdcab7 100644 --- a/source3/lib/util_str.c +++ b/source3/lib/util_str.c @@ -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); -- cgit