summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2011-05-18 13:57:26 +1000
committerAndrew Bartlett <abartlet@samba.org>2011-05-18 16:12:08 +0200
commit57f41ef150b82523aeb23cde63c1f8731a061edb (patch)
tree025e1fc7670e3a604cb2f302a991247e1037c88a
parentfa3e2fc8bb3e935c65b7043382cad1d649cb68a6 (diff)
downloadsamba-57f41ef150b82523aeb23cde63c1f8731a061edb.tar.gz
samba-57f41ef150b82523aeb23cde63c1f8731a061edb.tar.bz2
samba-57f41ef150b82523aeb23cde63c1f8731a061edb.zip
lib/util/charset use talloc_stackframe() rather than talloc_tos()
This is common code, and we can't assume a talloc_stackframe() so we must create it. Andrew Bartlett
-rw-r--r--lib/util/charset/util_str.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/lib/util/charset/util_str.c b/lib/util/charset/util_str.c
index e76c1dbbf5..80e5bde354 100644
--- a/lib/util/charset/util_str.c
+++ b/lib/util/charset/util_str.c
@@ -487,9 +487,10 @@ char *strstr_m(const char *src, const char *findstr)
const char *s;
char *s2;
char *retp;
-
size_t converted_size, findstr_len = 0;
+ TALLOC_CTX *frame; /* Only set up in the iconv case */
+
/* for correctness */
if (!findstr[0]) {
return discard_const_p(char, src);
@@ -524,35 +525,34 @@ char *strstr_m(const char *src, const char *findstr)
s = src;
#endif
- if (!push_ucs2_talloc(talloc_tos(), &src_w, src, &converted_size)) {
+ frame = talloc_stackframe();
+
+ if (!push_ucs2_talloc(frame, &src_w, src, &converted_size)) {
DEBUG(0,("strstr_m: src malloc fail\n"));
+ TALLOC_FREE(frame);
return NULL;
}
- if (!push_ucs2_talloc(talloc_tos(), &find_w, findstr, &converted_size)) {
- TALLOC_FREE(src_w);
+ if (!push_ucs2_talloc(frame, &find_w, findstr, &converted_size)) {
DEBUG(0,("strstr_m: find malloc fail\n"));
+ TALLOC_FREE(frame);
return NULL;
}
p = strstr_w(src_w, find_w);
if (!p) {
- TALLOC_FREE(src_w);
- TALLOC_FREE(find_w);
+ TALLOC_FREE(frame);
return NULL;
}
*p = 0;
- if (!pull_ucs2_talloc(talloc_tos(), &s2, src_w, &converted_size)) {
- TALLOC_FREE(src_w);
- TALLOC_FREE(find_w);
+ if (!pull_ucs2_talloc(frame, &s2, src_w, &converted_size)) {
+ TALLOC_FREE(frame);
DEBUG(0,("strstr_m: dest malloc fail\n"));
return NULL;
}
retp = discard_const_p(char, (s+strlen(s2)));
- TALLOC_FREE(src_w);
- TALLOC_FREE(find_w);
- TALLOC_FREE(s2);
+ TALLOC_FREE(frame);
return retp;
}