summaryrefslogtreecommitdiff
path: root/libarchive/archive_util.c
diff options
context:
space:
mode:
authorMichihiro NAKAJIMA <ggcueroad@gmail.com>2014-07-06 12:06:15 +0900
committerMichihiro NAKAJIMA <ggcueroad@gmail.com>2014-07-06 12:40:04 +0900
commitae086fb2635b8e89a7f0a9ce65b80b8c641576e0 (patch)
tree6cb39b1d88e77f77ce6017044a8a2fd462ba12a5 /libarchive/archive_util.c
parent96f3876ef4d24a10a77219c7244aa3a83c584d10 (diff)
downloadlibarchive-ae086fb2635b8e89a7f0a9ce65b80b8c641576e0.tar.gz
Plug memory leaks which Clang Static Analyser pointed out.
Diffstat (limited to 'libarchive/archive_util.c')
-rw-r--r--libarchive/archive_util.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/libarchive/archive_util.c b/libarchive/archive_util.c
index 3d92566b..a6a485c6 100644
--- a/libarchive/archive_util.c
+++ b/libarchive/archive_util.c
@@ -566,8 +566,11 @@ archive_utility_string_sort_helper(char **strings, unsigned int n)
{
lesser_count++;
tmp = (char **)realloc(lesser, lesser_count * sizeof(char *));
- if (!tmp)
+ if (!tmp) {
+ free(greater);
+ free(lesser);
return (ARCHIVE_FATAL);
+ }
lesser = tmp;
lesser[lesser_count - 1] = strings[i];
}
@@ -575,8 +578,11 @@ archive_utility_string_sort_helper(char **strings, unsigned int n)
{
greater_count++;
tmp = (char **)realloc(greater, greater_count * sizeof(char *));
- if (!tmp)
+ if (!tmp) {
+ free(greater);
+ free(lesser);
return (ARCHIVE_FATAL);
+ }
greater = tmp;
greater[greater_count - 1] = strings[i];
}