summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2003-12-01 22:46:49 +0000
committerJeremy Allison <jra@samba.org>2003-12-01 22:46:49 +0000
commitb91cff3fc5ccb9b08336c89e1a1e94959e15ee88 (patch)
tree08f1246ce257a988b93d92bd38f6bf9f092e26f5 /source3
parent8ecfda5c07255365e67f760a2a5be651ace6518b (diff)
downloadsamba-b91cff3fc5ccb9b08336c89e1a1e94959e15ee88.tar.gz
samba-b91cff3fc5ccb9b08336c89e1a1e94959e15ee88.tar.bz2
samba-b91cff3fc5ccb9b08336c89e1a1e94959e15ee88.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 e122891bebd33fc7bd654146a5cbec1feb307555)
Diffstat (limited to 'source3')
-rw-r--r--source3/lib/charcnv.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/source3/lib/charcnv.c b/source3/lib/charcnv.c
index 9d15c6daa0..d6eb336d31 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;
}