Fix heap-use-after-free issue flagged by fuzzer test.

A data member of class MtpFfsHandle is being accessed after the class object has been freed in the fuzzer. The method accessing the data member is running in a separate thread that gets detached from its parent. Using a conditional variable with an atomic int predicate in the close() function to ensure the detached thread's execution has completed before freeing the object fixes the issue without blocking the processing mid-way.

Bug: 243381410
Test: Build mtp_handle_fuzzer and run on the target device
Change-Id: I41dde165a5eba151c958b81417d9e1065af1b411
Merged-In: I41dde165a5eba151c958b81417d9e1065af1b411
(cherry picked from commit 50bf46a3f62136386548a9187a749936bda3ee8f)
2 files changed