diff options
author | Jeremy Allison <jra@samba.org> | 2003-12-01 22:46:46 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2003-12-01 22:46:46 +0000 |
commit | c4167baca1f8890a1fccce2273f1809def3d9703 (patch) | |
tree | aaa35ee9dc9df27a9ad397dca25323ce9f2a66f2 /source3 | |
parent | 70e2f0944aab041926c9c4a2f24fb0ed28b8565a (diff) | |
download | samba-c4167baca1f8890a1fccce2273f1809def3d9703.tar.gz samba-c4167baca1f8890a1fccce2273f1809def3d9703.tar.bz2 samba-c4167baca1f8890a1fccce2273f1809def3d9703.zip |
Get a little paranoid about memfree use in convert_string_allocate..
Looking at crash bugs #809 and others.
Jeremy.
(This used to be commit cd2075580b0f35c8a414c995f03834c01efaa9be)
Diffstat (limited to 'source3')
-rw-r--r-- | source3/lib/charcnv.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/source3/lib/charcnv.c b/source3/lib/charcnv.c index 0a6a1fc75d..6a00402193 100644 --- a/source3/lib/charcnv.c +++ b/source3/lib/charcnv.c @@ -488,7 +488,6 @@ convert: } } - /** * Convert between character sets, allocating a new buffer using talloc for the result. * @@ -581,19 +580,19 @@ char *strdup_upper(const char *s) size_t unix_strlower(const char *src, size_t srclen, char *dest, size_t destlen) { size_t size; - smb_ucs2_t *buffer; + smb_ucs2_t *buffer = NULL; size = convert_string_allocate(NULL, CH_UNIX, CH_UCS2, src, srclen, (void **) &buffer); - if (size == -1) { + if (size == -1 || !buffer) { smb_panic("failed to create UCS2 buffer"); } if (!strlower_w(buffer) && (dest == src)) { - free(buffer); + SAFE_FREE(buffer); return srclen; } size = convert_string(CH_UCS2, CH_UNIX, buffer, size, dest, destlen); - free(buffer); + SAFE_FREE(buffer); return size; } @@ -604,11 +603,11 @@ size_t unix_strlower(const char *src, size_t srclen, char *dest, size_t destlen) char *strdup_lower(const char *s) { size_t size; - smb_ucs2_t *buffer; + smb_ucs2_t *buffer = NULL; char *out_buffer; size = push_ucs2_allocate(&buffer, s); - if (size == -1) { + if (size == -1 || !buffer) { return NULL; } |