Fix for #387 - Patch from Milan Crha
authorJulien Kerihuel <j.kerihuel@openchange.org>
Wed, 29 Feb 2012 12:43:30 +0000 (12:43 +0000)
committerJulien Kerihuel <j.kerihuel@openchange.org>
Wed, 29 Feb 2012 12:43:30 +0000 (12:43 +0000)
libmapi/fxparser.c

index 183ca3ce4389552e603852afd21fef28a3c6de72..827b8fee5861d2a229157cd22fac969a3a686dd6 100644 (file)
@@ -224,7 +224,7 @@ static bool fetch_ucs2_data(struct fx_parser_context *parser, uint32_t numbytes,
                return false;
        }
 
-       *data_read = talloc_array(parser->mem_ctx, smb_ucs2_t, numbytes/2);
+       *data_read = talloc_zero_array(parser->mem_ctx, smb_ucs2_t, (numbytes/2) + 1);
        memcpy(*data_read, &(parser->data.data[parser->idx]), numbytes);
        parser->idx += numbytes;
        return true;
@@ -261,7 +261,7 @@ static bool pull_unicode(struct fx_parser_context *parser, char **pstr)
            parser->idx + length > parser->data.length)
                return false;
 
-       ucs2_data = talloc_array(parser->mem_ctx, smb_ucs2_t, length/2);
+       ucs2_data = talloc_zero_array(parser->mem_ctx, smb_ucs2_t, (length/2) + 1);
 
        if (!fetch_ucs2_data(parser, length, &ucs2_data)) {
                return false;