Gtk: Clean up asan leaks.

This commit is contained in:
BearOso 2023-02-08 12:06:47 -06:00
parent 3bbed09867
commit 2fb67c7329
7 changed files with 37 additions and 13 deletions

View File

@ -1562,6 +1562,7 @@ s9xcommand_t S9xGetCommandT (const char *name)
cmd.button.multi_idx = multis.size() - 1; cmd.button.multi_idx = multis.size() - 1;
cmd.type = S9xButtonMulti; cmd.type = S9xButtonMulti;
free(c);
} }
else else
{ {

View File

@ -65,6 +65,16 @@ void S9xParsePortConfig(ConfigFile &conf, int pass)
Snes9xConfig::Snes9xConfig() Snes9xConfig::Snes9xConfig()
{ {
joystick_threshold = 40; joystick_threshold = 40;
xrr_crtc_info = nullptr;
xrr_screen_resources = nullptr;
}
Snes9xConfig::~Snes9xConfig()
{
if (xrr_crtc_info)
XRRFreeCrtcInfo(xrr_crtc_info);
if (xrr_screen_resources)
XRRFreeScreenResources(xrr_screen_resources);
} }
int Snes9xConfig::load_defaults() int Snes9xConfig::load_defaults()

View File

@ -48,6 +48,7 @@ class Snes9xConfig
{ {
public: public:
Snes9xConfig(); Snes9xConfig();
~Snes9xConfig();
int load_config_file(); int load_config_file();
int save_config_file(); int save_config_file();
int load_defaults(); int load_defaults();

View File

@ -793,7 +793,9 @@ void S9xQueryDrivers()
Window xid = gdk_x11_window_get_xid(top_level->window->get_window()->gobj()); Window xid = gdk_x11_window_get_xid(top_level->window->get_window()->gobj());
gui_config->allow_xrandr = true; gui_config->allow_xrandr = true;
if (!gui_config->xrr_screen_resources)
gui_config->xrr_screen_resources = XRRGetScreenResourcesCurrent(dpy, xid); gui_config->xrr_screen_resources = XRRGetScreenResourcesCurrent(dpy, xid);
if (!gui_config->xrr_crtc_info)
gui_config->xrr_crtc_info = XRRGetCrtcInfo(dpy, gui_config->xrr_crtc_info = XRRGetCrtcInfo(dpy,
gui_config->xrr_screen_resources, gui_config->xrr_screen_resources,
gui_config->xrr_screen_resources->crtcs[0]); gui_config->xrr_screen_resources->crtcs[0]);

View File

@ -60,6 +60,7 @@ bool GTKGLXContext::attach(Display *dpy, Window xid)
} }
fbconfig = fbconfigs[0]; fbconfig = fbconfigs[0];
free(fbconfigs);
return true; return true;
} }

View File

@ -1167,20 +1167,28 @@ void Snes9xWindow::enter_fullscreen_mode()
{ {
Display *dpy = gdk_x11_display_get_xdisplay(gdk_display); Display *dpy = gdk_x11_display_get_xdisplay(gdk_display);
auto xrr_screen_resources = XRRGetScreenResourcesCurrent(dpy, gdk_x11_window_get_xid(gdk_window));
auto xrr_crtc_info = XRRGetCrtcInfo(dpy,
xrr_screen_resources,
xrr_screen_resources->crtcs[0]);
gdk_display_sync(gdk_display); gdk_display_sync(gdk_display);
if (XRRSetCrtcConfig(dpy, if (XRRSetCrtcConfig(dpy,
config->xrr_screen_resources, xrr_screen_resources,
config->xrr_screen_resources->crtcs[0], xrr_screen_resources->crtcs[0],
CurrentTime, CurrentTime,
config->xrr_crtc_info->x, xrr_crtc_info->x,
config->xrr_crtc_info->y, xrr_crtc_info->y,
config->xrr_screen_resources->modes[config->xrr_index].id, xrr_screen_resources->modes[config->xrr_index].id,
config->xrr_crtc_info->rotation, xrr_crtc_info->rotation,
&config->xrr_crtc_info->outputs[0], &xrr_crtc_info->outputs[0],
1) != 0) 1) != 0)
{ {
config->change_display_resolution = 0; config->change_display_resolution = 0;
} }
XRRFreeCrtcInfo(xrr_crtc_info);
XRRFreeScreenResources(xrr_screen_resources);
if (gui_config->auto_input_rate) if (gui_config->auto_input_rate)
{ {

View File

@ -10,11 +10,12 @@ namespace Vulkan
Context::Context() Context::Context()
{ {
auto dl = new vk::DynamicLoader; vk::DynamicLoader dl;
auto vkGetInstanceProcAddr = auto vkGetInstanceProcAddr =
dl->getProcAddress<PFN_vkGetInstanceProcAddr>("vkGetInstanceProcAddr"); dl.getProcAddress<PFN_vkGetInstanceProcAddr>("vkGetInstanceProcAddr");
VULKAN_HPP_DEFAULT_DISPATCHER.init(vkGetInstanceProcAddr); VULKAN_HPP_DEFAULT_DISPATCHER.init(vkGetInstanceProcAddr);
} }
Context::~Context() Context::~Context()