summaryrefslogtreecommitdiffstats
path: root/fs_mgr
diff options
context:
space:
mode:
authorChristopher Morin <cmtm@google.com>2018-01-08 09:58:20 +0000
committerandroid-build-merger <android-build-merger@google.com>2018-01-08 09:58:20 +0000
commitb22632cd9dbad39c2983896e3487575fb5017f76 (patch)
treef0e6ad197d74d230f0bad0d28136bb8758c5e3a3 /fs_mgr
parent672fbe53f4a4f8af0b45435f4eac911821adfb88 (diff)
parenta7f3fef5cbf6b2eb5e2b63a554adc7e182045d34 (diff)
downloadsystem_core-b22632cd9dbad39c2983896e3487575fb5017f76.tar.gz
system_core-b22632cd9dbad39c2983896e3487575fb5017f76.tar.bz2
system_core-b22632cd9dbad39c2983896e3487575fb5017f76.zip
Merge "fs_mgr: fix memory leak" am: 9bbcea1878 am: 9b205334d6
am: a7f3fef5cb Change-Id: Idc2b90bc0a66131769b006f10f09cf92d3c4ccee
Diffstat (limited to 'fs_mgr')
-rw-r--r--fs_mgr/fs_mgr_fstab.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/fs_mgr/fs_mgr_fstab.cpp b/fs_mgr/fs_mgr_fstab.cpp
index 34afed1a4..d913af039 100644
--- a/fs_mgr/fs_mgr_fstab.cpp
+++ b/fs_mgr/fs_mgr_fstab.cpp
@@ -654,12 +654,13 @@ static struct fstab *in_place_merge(struct fstab *a, struct fstab *b)
}
for (int i = a->num_entries, j = 0; i < total_entries; i++, j++) {
- // copy the pointer directly *without* malloc and memcpy
+ // Copy the structs by assignment.
a->recs[i] = b->recs[j];
}
- // Frees up b, but don't free b->recs[X] to make sure they are
- // accessible through a->recs[X].
+ // We can't call fs_mgr_free_fstab because a->recs still references the
+ // memory allocated by strdup.
+ free(b->recs);
free(b->fstab_filename);
free(b);