summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/lib/util_str.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/source3/lib/util_str.c b/source3/lib/util_str.c
index 394c8e27cf..f99c2d1fb3 100644
--- a/source3/lib/util_str.c
+++ b/source3/lib/util_str.c
@@ -2016,10 +2016,16 @@ char * base64_encode_data_blob(DATA_BLOB data)
{
int bits = 0;
int char_count = 0;
- size_t out_cnt = 0;
- size_t len = data.length;
- size_t output_len = data.length * 2;
- char *result = SMB_MALLOC(output_len); /* get us plenty of space */
+ size_t out_cnt, len, output_len;
+ char *result;
+
+ if (!data.length || !data.data)
+ return NULL;
+
+ out_cnt = 0;
+ len = data.length;
+ output_len = data.length * 2;
+ result = SMB_MALLOC(output_len); /* get us plenty of space */
while (len-- && out_cnt < (data.length * 2) - 5) {
int c = (unsigned char) *(data.data++);