From 1b03fc549311f66e14d789c734b609ccca9a1fd3 Mon Sep 17 00:00:00 2001 From: George Burgess IV Date: Wed, 23 Oct 2019 12:09:07 -0700 Subject: bootable: leak less memory `misc_device_` is a std::string, so it allocates and manages its own memory. Hence, the strdup here is immediately leaked. Caught by the static analyzer Bug: None Test: TreeHugger Change-Id: Iffb1ff60f6087e470a0979d202150567272e8b1c --- boot_control/libboot_control.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/boot_control/libboot_control.cpp b/boot_control/libboot_control.cpp index e3bff9ff3..ff4eaabfa 100644 --- a/boot_control/libboot_control.cpp +++ b/boot_control/libboot_control.cpp @@ -218,7 +218,8 @@ bool BootControl::Init() { } // Note that since there isn't a module unload function this memory is leaked. - misc_device_ = strdup(device.c_str()); + // We use `device` below sometimes, so it's not moved out of here. + misc_device_ = device; initialized_ = true; // Validate the loaded data, otherwise we will destroy it and re-initialize it -- cgit v1.2.3