Skip to content
Snippets Groups Projects
Commit 945a49cf authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen
Browse files

test: Fix a potential use-after-free when using stopAsync

Since we're now using an async stop function, we might be freeing the
buffer while it's still being used.
Instead, release it automatically after the instance itself has been
released since we're guaranteed to have joined all threads at this point
parent 1029f7b5
No related branches found
No related tags found
1 merge request!20test: Fix a potential use-after-free when using stopAsync
Pipeline #184607 passed with stage
in 1 minute and 21 seconds
......@@ -34,6 +34,9 @@ int main(int ac, char** av)
return 1;
}
const char* vlcArgs = "-vv";
auto imgBuffer = malloc(480 * 320 * 4);
std::unique_ptr<uint8_t, decltype(&free)> imgBufferPtr{
static_cast<uint8_t*>( imgBuffer ), &free };
auto instance = VLC::Instance(1, &vlcArgs);
#if LIBVLC_VERSION_INT >= LIBVLC_VERSION(3, 0, 0, 0)
......@@ -57,7 +60,6 @@ int main(int ac, char** av)
std::cout << media.mrl() << " is playing" << std::endl;
});
auto imgBuffer = malloc(480 * 320 * 4);
mp.setVideoCallbacks([imgBuffer](void** pBuffer) -> void* {
std::cout << "Lock" << std::endl;
*pBuffer = imgBuffer;
......@@ -169,7 +171,6 @@ int main(int ac, char** av)
{
std::cout << f.name() << std::endl;
}
free(imgBuffer);
// Check that we don't use the old media player when releasing its event manager
mp = VLC::MediaPlayer{};
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment