From 2a004f09112897543ce667acd162393680ba2b4d Mon Sep 17 00:00:00 2001 From: szaka Date: Mon, 22 Dec 2008 00:16:19 +0000 Subject: [PATCH] ntfs_utf16_to_utf8, ntfs_utf8_to_utf16: check ntfs_malloc() return value --- libntfs-3g/unistr.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/libntfs-3g/unistr.c b/libntfs-3g/unistr.c index 3cd45dac..2877722e 100644 --- a/libntfs-3g/unistr.c +++ b/libntfs-3g/unistr.c @@ -485,8 +485,12 @@ static int ntfs_utf16_to_utf8(const ntfschar *ins, const int ins_len, if (size < 0) goto out; - if (!*outs) - *outs = ntfs_malloc((outs_len = size + 1)); + if (!*outs) { + outs_len = size + 1; + *outs = ntfs_malloc(outs_len); + if (!*outs) + goto out; + } t = *outs; @@ -666,8 +670,11 @@ static int ntfs_utf8_to_utf16(const char *ins, ntfschar **outs) if (shorts < 0) goto fail; - if (!*outs) - *outs = ntfs_malloc((shorts+1) * sizeof(ntfschar)); + if (!*outs) { + *outs = ntfs_malloc((shorts + 1) * sizeof(ntfschar)); + if (!*outs) + goto fail; + } outpos = *outs;