aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorN-R-K <79544946+N-R-K@users.noreply.github.com>2021-10-28 07:57:03 +0600
committerGitHub <noreply@github.com>2021-10-28 01:57:03 +0000
commit7e7eaf08f12d43e2eb2d425a08c5c5ad52b17bb1 (patch)
tree4936c56ed08735c58d093a95ae9a2d66bfe39c66
parent57754572bc20769575b888565dc192c9d6e14f05 (diff)
fix: memory leak due to not destroying XrmDatabase (#134)
-rw-r--r--window.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/window.c b/window.c
index 1c4eed6..bfa1a71 100644
--- a/window.c
+++ b/window.c
@@ -92,7 +92,7 @@ const char* win_res(XrmDatabase db, const char *name, const char *def)
char *type;
XrmValue ret;
- if (db != None &&
+ if (db != NULL &&
XrmGetResource(db, name, name, &type, &ret) &&
STREQ(type, "String"))
{
@@ -130,7 +130,7 @@ void win_init(win_t *win)
XrmInitialize();
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_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;
#endif /* HAVE_LIBFONTS */
+ XrmDestroyDatabase(db);
INIT_ATOM_(WM_DELETE_WINDOW);
INIT_ATOM_(_NET_WM_NAME);
INIT_ATOM_(_NET_WM_ICON_NAME);