From 1b7b9eef9897c3126b94163fd820ad691cb59825 Mon Sep 17 00:00:00 2001 From: Sho Amano Date: Mon, 19 Jun 2017 22:05:04 +0900 Subject: fix: memory issue in FromMicToFileRecorderThread Strings were not copied properly, instead pointers to buffers were copied. One of the buffer was released immediately, causing memory access through a dangling pointer. --- .../src/audio/from_mic_to_file_recorder_thread.cc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/components/media_manager/src/audio/from_mic_to_file_recorder_thread.cc b/src/components/media_manager/src/audio/from_mic_to_file_recorder_thread.cc index 0239795d75..a514959701 100644 --- a/src/components/media_manager/src/audio/from_mic_to_file_recorder_thread.cc +++ b/src/components/media_manager/src/audio/from_mic_to_file_recorder_thread.cc @@ -32,6 +32,7 @@ #include "media_manager/audio/from_mic_to_file_recorder_thread.h" #include +#include #include #include "utils/logger.h" @@ -88,11 +89,11 @@ void FromMicToFileRecorderThread::initArgs() { argv_[3] = new gchar[3]; argv_[4] = new gchar[durationString_.length() + 1]; - argv_[0] = const_cast(std::string("AudioManager").c_str()); - argv_[1] = const_cast(oKey_.c_str()); - argv_[2] = const_cast(outputFileName_.c_str()); - argv_[3] = const_cast(tKey_.c_str()); - argv_[4] = const_cast(durationString_.c_str()); + std::strcpy(argv_[0], "AudioManager"); + std::strcpy(argv_[1], oKey_.c_str()); + std::strcpy(argv_[2], outputFileName_.c_str()); + std::strcpy(argv_[3], tKey_.c_str()); + std::strcpy(argv_[4], durationString_.c_str()); } void FromMicToFileRecorderThread::threadMain() { -- cgit v1.2.1