diff --git a/a.diff b/a.diff new file mode 100644 index 0000000000000000000000000000000000000000..87edaa2668e6330f763f22768f34a3e3cca845f9 --- /dev/null +++ b/a.diff @@ -0,0 +1,44 @@ +diff --git a/frameworks/native/system_sound_manager/system_sound_manager_impl.cpp b/frameworks/native/system_sound_manager/system_sound_manager_impl.cpp +index 0cb7f55d7274e1e6beccb6c9a6fc5d6f802bc6a6..9ac507e410faca6b30a9b587e14527416694039d 100644 +--- a/frameworks/native/system_sound_manager/system_sound_manager_impl.cpp ++++ b/frameworks/native/system_sound_manager/system_sound_manager_impl.cpp +@@ -1783,7 +1783,7 @@ std::string SystemSoundManagerImpl::AddCustomizedToneByExternalUri( + MEDIA_LOGI("AddCustomizedToneByExternalUri: Start, externalUri: %{public}s", externalUri.c_str()); + std::string fdHead = "fd://"; + std::string srcPath = externalUri; +- int32_t srcFd; ++ int32_t srcFd = -1; + if (srcPath.find(fdHead) != std::string::npos) { + StrToInt(srcPath.substr(fdHead.size()), srcFd); + } else { +@@ -1794,7 +1794,9 @@ std::string SystemSoundManagerImpl::AddCustomizedToneByExternalUri( + fdHead.clear(); + return fdHead; + } +- return AddCustomizedToneByFd(context, toneAttrs, srcFd); ++ std::string result = AddCustomizedToneByFd(context, toneAttrs, srcFd); ++ close(srcFd); ++ return result; + } + + std::string SystemSoundManagerImpl::AddCustomizedToneByFd(const std::shared_ptr &context, +@@ -1982,7 +1984,6 @@ std::string SystemSoundManagerImpl::CustomizedToneWriteFile(const std::shared_pt + } + len -= bytesWritten; + } +- close(paramsForWriteFile.srcFd); + close(dstFd); + dataShareHelper->Release(); + SendCustomizedToneEvent(true, toneAttrs, paramsForWriteFile.fileSize, mimeType_, SUCCESS); +diff --git a/frameworks/native/system_sound_manager/system_sound_vibrator/system_sound_vibrator.cpp b/frameworks/native/system_sound_manager/system_sound_vibrator/system_sound_vibrator.cpp +index 2451e2e9a65d590766c933f901ad534dd241baff..2df01f8b49a839671dbed934cb593ed828034b74 100644 +--- a/frameworks/native/system_sound_manager/system_sound_vibrator/system_sound_vibrator.cpp ++++ b/frameworks/native/system_sound_manager/system_sound_vibrator/system_sound_vibrator.cpp +@@ -302,6 +302,7 @@ int32_t SystemSoundVibrator::GetVibratorDuration(const std::string &hapticUri) + int32_t result = Sensors::PreProcess(vibratorFD, vibratorPkg); + if (result != 0) { + MEDIA_LOGE("Failed to pre-process hapticUri!"); ++ Sensors::FreeVibratorPackage(vibratorPkg); + return ret; + } + int32_t delayTime = 0; diff --git a/frameworks/native/system_sound_manager/system_sound_manager_impl.cpp b/frameworks/native/system_sound_manager/system_sound_manager_impl.cpp index 0cb7f55d7274e1e6beccb6c9a6fc5d6f802bc6a6..9ac507e410faca6b30a9b587e14527416694039d 100644 --- a/frameworks/native/system_sound_manager/system_sound_manager_impl.cpp +++ b/frameworks/native/system_sound_manager/system_sound_manager_impl.cpp @@ -1783,7 +1783,7 @@ std::string SystemSoundManagerImpl::AddCustomizedToneByExternalUri( MEDIA_LOGI("AddCustomizedToneByExternalUri: Start, externalUri: %{public}s", externalUri.c_str()); std::string fdHead = "fd://"; std::string srcPath = externalUri; - int32_t srcFd; + int32_t srcFd = -1; if (srcPath.find(fdHead) != std::string::npos) { StrToInt(srcPath.substr(fdHead.size()), srcFd); } else { @@ -1794,7 +1794,9 @@ std::string SystemSoundManagerImpl::AddCustomizedToneByExternalUri( fdHead.clear(); return fdHead; } - return AddCustomizedToneByFd(context, toneAttrs, srcFd); + std::string result = AddCustomizedToneByFd(context, toneAttrs, srcFd); + close(srcFd); + return result; } std::string SystemSoundManagerImpl::AddCustomizedToneByFd(const std::shared_ptr &context, @@ -1982,7 +1984,6 @@ std::string SystemSoundManagerImpl::CustomizedToneWriteFile(const std::shared_pt } len -= bytesWritten; } - close(paramsForWriteFile.srcFd); close(dstFd); dataShareHelper->Release(); SendCustomizedToneEvent(true, toneAttrs, paramsForWriteFile.fileSize, mimeType_, SUCCESS); diff --git a/frameworks/native/system_sound_manager/system_sound_vibrator/system_sound_vibrator.cpp b/frameworks/native/system_sound_manager/system_sound_vibrator/system_sound_vibrator.cpp index 2451e2e9a65d590766c933f901ad534dd241baff..2df01f8b49a839671dbed934cb593ed828034b74 100644 --- a/frameworks/native/system_sound_manager/system_sound_vibrator/system_sound_vibrator.cpp +++ b/frameworks/native/system_sound_manager/system_sound_vibrator/system_sound_vibrator.cpp @@ -302,6 +302,7 @@ int32_t SystemSoundVibrator::GetVibratorDuration(const std::string &hapticUri) int32_t result = Sensors::PreProcess(vibratorFD, vibratorPkg); if (result != 0) { MEDIA_LOGE("Failed to pre-process hapticUri!"); + Sensors::FreeVibratorPackage(vibratorPkg); return ret; } int32_t delayTime = 0;