summaryrefslogtreecommitdiff
path: root/source3/lib/charcnv.c
diff options
context:
space:
mode:
Diffstat (limited to 'source3/lib/charcnv.c')
-rw-r--r--source3/lib/charcnv.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/source3/lib/charcnv.c b/source3/lib/charcnv.c
index c4eeab135e..ae04fd9ffb 100644
--- a/source3/lib/charcnv.c
+++ b/source3/lib/charcnv.c
@@ -537,19 +537,17 @@ size_t convert_string_allocate(TALLOC_CTX *ctx, charset_t from, charset_t to,
destlen = destlen * 2;
}
- if (ctx)
+ if (ctx) {
ob = (char *)TALLOC_REALLOC(ctx, ob, destlen);
- else
+ } else {
ob = (char *)SMB_REALLOC(ob, destlen);
+ }
if (!ob) {
DEBUG(0, ("convert_string_allocate: realloc failed!\n"));
- if (!ctx)
- SAFE_FREE(outbuf);
return (size_t)-1;
- } else {
- outbuf = ob;
}
+ outbuf = ob;
i_len = srclen;
o_len = destlen;
@@ -587,17 +585,18 @@ size_t convert_string_allocate(TALLOC_CTX *ctx, charset_t from, charset_t to,
out:
destlen = destlen - o_len;
- if (ctx)
- *dest = (char *)TALLOC_REALLOC(ctx,ob,destlen);
- else
- *dest = (char *)SMB_REALLOC(ob,destlen);
- if (destlen && !*dest) {
+ if (ctx) {
+ ob = (char *)TALLOC_REALLOC(ctx,ob,destlen);
+ } else {
+ ob = (char *)SMB_REALLOC(ob,destlen);
+ }
+
+ if (destlen && !ob) {
DEBUG(0, ("convert_string_allocate: out of memory!\n"));
- if (!ctx)
- SAFE_FREE(ob);
return (size_t)-1;
}
+ *dest = ob;
return destlen;
use_as_is: