platform: msm_shared: Correctly free the buffer of str_target
The str_target maybe not as the return value of str_align_right,
at that case there is some error when trying to free a const string.
Change-Id: Ia5fc71b3e4edeca7593f88eae62cbd5f23955554
diff --git a/platform/msm_shared/display_menu.c b/platform/msm_shared/display_menu.c
index 391e5ff..8b74c9a 100644
--- a/platform/msm_shared/display_menu.c
+++ b/platform/msm_shared/display_menu.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2015-2018, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -201,14 +201,10 @@
for (i = 0; i < diff; i++) {
strlcat(str_target, " ", max_x);
}
- strlcat(str_target, str, max_x);
- return str_target;
- } else {
- free(str_target);
- return str;
}
+ strlcat(str_target, str, max_x);
}
- return str;
+ return str_target;
}
/* msg_lock need to be holded when call this function. */