Move Cleanup and framebuffer freeing into Close() so that we don't crash on Reload

This commit is contained in:
Isaac Connor 2021-11-29 16:21:34 -05:00
parent a0fd8d64d2
commit 5fdad04a9e
1 changed files with 7 additions and 6 deletions

View File

@ -23,7 +23,7 @@ void bind_libvnc_symbols() {
libvnc_lib = dlopen("libvncclient.so", RTLD_LAZY | RTLD_GLOBAL); libvnc_lib = dlopen("libvncclient.so", RTLD_LAZY | RTLD_GLOBAL);
if (!libvnc_lib) { if (!libvnc_lib) {
Error("Error loading libvncclient: %s", dlerror()); Error("Error loading libvncclient.so: %s", dlerror());
return; return;
} }
@ -135,11 +135,6 @@ VncCamera::VncCamera(
} }
VncCamera::~VncCamera() { VncCamera::~VncCamera() {
if (capture and mRfb) {
if (mRfb->frameBuffer)
free(mRfb->frameBuffer);
(*rfbClientCleanup_f)(mRfb);
}
if (libvnc_lib) { if (libvnc_lib) {
dlclose(libvnc_lib); dlclose(libvnc_lib);
libvnc_lib = nullptr; libvnc_lib = nullptr;
@ -253,6 +248,12 @@ int VncCamera::PostCapture() {
} }
int VncCamera::Close() { int VncCamera::Close() {
if (capture and mRfb) {
if (mRfb->frameBuffer)
free(mRfb->frameBuffer);
(*rfbClientCleanup_f)(mRfb);
mRfb = nullptr;
}
return 1; return 1;
} }
#endif #endif