fix: memory leak due to not destroying XrmDatabase (#134)

This commit is contained in:
N-R-K 2021-10-28 07:57:03 +06:00 committed by GitHub
parent 57754572bc
commit 7e7eaf08f1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -92,7 +92,7 @@ const char* win_res(XrmDatabase db, const char *name, const char *def)
char *type; char *type;
XrmValue ret; XrmValue ret;
if (db != None && if (db != NULL &&
XrmGetResource(db, name, name, &type, &ret) && XrmGetResource(db, name, name, &type, &ret) &&
STREQ(type, "String")) STREQ(type, "String"))
{ {
@ -130,7 +130,7 @@ void win_init(win_t *win)
XrmInitialize(); XrmInitialize();
res_man = XResourceManagerString(e->dpy); res_man = XResourceManagerString(e->dpy);
db = res_man != NULL ? XrmGetStringDatabase(res_man) : None; db = res_man == NULL ? NULL : XrmGetStringDatabase(res_man);
win_bg = win_res(db, RES_CLASS ".window.background", "white"); win_bg = win_res(db, RES_CLASS ".window.background", "white");
win_fg = win_res(db, RES_CLASS ".window.foreground", "black"); win_fg = win_res(db, RES_CLASS ".window.foreground", "black");
@ -158,6 +158,7 @@ void win_init(win_t *win)
win->bar.h = options->hide_bar ? 0 : barheight; win->bar.h = options->hide_bar ? 0 : barheight;
#endif /* HAVE_LIBFONTS */ #endif /* HAVE_LIBFONTS */
XrmDestroyDatabase(db);
INIT_ATOM_(WM_DELETE_WINDOW); INIT_ATOM_(WM_DELETE_WINDOW);
INIT_ATOM_(_NET_WM_NAME); INIT_ATOM_(_NET_WM_NAME);
INIT_ATOM_(_NET_WM_ICON_NAME); INIT_ATOM_(_NET_WM_ICON_NAME);