Change localtime to localtime_r for thread safety 74/266174/1
authorwn.jang <wn.jang@samsung.com>
Tue, 9 Nov 2021 02:02:05 +0000 (11:02 +0900)
committerwn.jang <wn.jang@samsung.com>
Tue, 9 Nov 2021 02:02:05 +0000 (11:02 +0900)
Change-Id: I809c8460625f2a10641252b6f0f43ec3853e12e6

src/service_main.cpp

index 866cf20..e3482e6 100644 (file)
@@ -341,7 +341,9 @@ int CServiceMain::client_set_background_volume(pid_t pid, double ratio)
        for (auto item : history) {
                std::time_t time_info = std::get<3>(item);
                char time_string[32];
-               std::strftime(time_string, sizeof(time_string), "%H%M%S", std::localtime(&time_info));
+               struct tm tm;
+               localtime_r(&time_info, &tm);
+               std::strftime(time_string, sizeof(time_string), "%H%M%S", &tm);
                ss << "[";
                ss << std::get<0>(item);
                ss << ",";