[vlc-commits] [Git][videolan/libvlcpp][master] test: Fix a potential use-after-free when using stopAsync
Hugo Beauzée-Luyssen (@chouquette)
gitlab at videolan.org
Fri Jan 28 14:16:59 UTC 2022
Hugo Beauzée-Luyssen pushed to branch master at VideoLAN / libvlcpp
Commits:
945a49cf by Hugo Beauzée-Luyssen at 2022-01-28T15:15:04+01:00
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
- - - - -
1 changed file:
- test/main.cpp
Changes:
=====================================
test/main.cpp
=====================================
@@ -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{};
}
View it on GitLab: https://code.videolan.org/videolan/libvlcpp/-/commit/945a49cf0e802745e19bb615fdf288aa1b4e1026
--
View it on GitLab: https://code.videolan.org/videolan/libvlcpp/-/commit/945a49cf0e802745e19bb615fdf288aa1b4e1026
You're receiving this email because of your account on code.videolan.org.
More information about the vlc-commits
mailing list