Got questions, comments, patches, etc.?
Contact Jason Woofenden
gitweb
/
spectrwm.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
plug memleak in find_window
[spectrwm.git]
/
spectrwm.c
diff --git
a/spectrwm.c
b/spectrwm.c
index
b36aee1
..
1751412
100644
(file)
--- a/
spectrwm.c
+++ b/
spectrwm.c
@@
-647,7
+647,6
@@
struct ewmh_hint {
};
/* function prototypes */
};
/* function prototypes */
-xcb_char2b_t *char2b(const char *);
int conf_load(char *, int);
void constrain_window(struct ws_win *, struct swm_region *, int);
void do_sync(void);
int conf_load(char *, int);
void constrain_window(struct ws_win *, struct swm_region *, int);
void do_sync(void);
@@
-672,26
+671,6
@@
void update_window(struct ws_win *);
char *get_atom_name(xcb_atom_t);
#endif
char *get_atom_name(xcb_atom_t);
#endif
-/* function definitions */
-xcb_char2b_t *
-char2b(const char *str)
-{
- xcb_char2b_t *s;
- size_t i, len;
-
- len = strlen(str);
- s = malloc(len * sizeof(xcb_char2b_t));
- if (!s)
- return (NULL);
-
- for (i = 0; i < len; i++) {
- s[i].byte1 = '\0';
- s[i].byte2 = str[i];
- }
-
- return (s);
-}
-
int
parse_rgb(const char *rgb, uint16_t *rr, uint16_t *gg, uint16_t *bb)
{
int
parse_rgb(const char *rgb, uint16_t *rr, uint16_t *gg, uint16_t *bb)
{
@@
-841,7
+820,7
@@
teardown_ewmh(void)
pc = xcb_get_property(conn, 0, screens[i].root, sup_check,
XCB_ATOM_WINDOW, 0, 1);
pr = xcb_get_property_reply(conn, pc, NULL);
pc = xcb_get_property(conn, 0, screens[i].root, sup_check,
XCB_ATOM_WINDOW, 0, 1);
pr = xcb_get_property_reply(conn, pc, NULL);
- if (pr->format == sup_check) {
+ if (pr && pr->format == sup_check) {
id = *((xcb_window_t *)xcb_get_property_value(pr));
xcb_destroy_window(conn, id);
id = *((xcb_window_t *)xcb_get_property_value(pr));
xcb_destroy_window(conn, id);
@@
-2320,8
+2299,10
@@
find_window(xcb_window_t id)
return (NULL);
/* if we were looking for the parent return that window instead */
return (NULL);
/* if we were looking for the parent return that window instead */
- if (r->parent == 0 || r->root == r->parent)
+ if (r->parent == 0 || r->root == r->parent) {
+ free(r);
return (NULL);
return (NULL);
+ }
/* look for parent */
for (i = 0; i < num_screens; i++)
/* look for parent */
for (i = 0; i < num_screens; i++)
@@
-3751,12
+3732,10
@@
get_win_name(xcb_window_t win)
if (xcb_icccm_get_wm_name_reply(conn, c, &r, NULL)) {
if (r.name_len > 0) {
name = malloc(r.name_len + 1);
if (xcb_icccm_get_wm_name_reply(conn, c, &r, NULL)) {
if (r.name_len > 0) {
name = malloc(r.name_len + 1);
- if (!name) {
- xcb_icccm_get_text_property_reply_wipe(&r);
- return (NULL);
+ if (name) {
+ memcpy(name, r.name, r.name_len);
+ name[r.name_len] = '\0';
}
}
- memcpy(name, r.name, r.name_len);
- name[r.name_len] = '\0';
}
xcb_icccm_get_text_property_reply_wipe(&r);
}
}
xcb_icccm_get_text_property_reply_wipe(&r);
}
@@
-6443,7
+6422,7
@@
get_ws_idx(xcb_window_t id)
xcb_get_property(conn, 0, id, a_swm_ws,
XCB_ATOM_STRING, 0, SWM_PROPLEN),
NULL);
xcb_get_property(conn, 0, id, a_swm_ws,
XCB_ATOM_STRING, 0, SWM_PROPLEN),
NULL);
- if (gpr->type) {
+ if (gpr && gpr->type) {
proplen = xcb_get_property_value_length(gpr);
if (proplen > 0) {
prop = malloc(proplen + 1);
proplen = xcb_get_property_value_length(gpr);
if (proplen > 0) {
prop = malloc(proplen + 1);
@@
-6464,6
+6443,7
@@
get_ws_idx(xcb_window_t id)
DNPRINTF(SWM_D_PROP, "get_ws_idx: window: #%s: %s",
errstr, prop);
}
DNPRINTF(SWM_D_PROP, "get_ws_idx: window: #%s: %s",
errstr, prop);
}
+ free(prop);
}
return ws_idx;
}
return ws_idx;
@@
-7115,7
+7095,7
@@
maprequest(xcb_map_request_event_t *e)
char *
get_atom_name(xcb_atom_t atom)
{
char *
get_atom_name(xcb_atom_t atom)
{
- char *name;
+ char *name = NULL;
size_t len;
xcb_get_atom_name_reply_t *r;
size_t len;
xcb_get_atom_name_reply_t *r;
@@
-7129,14
+7109,12
@@
get_atom_name(xcb_atom_t atom)
if (name) {
memcpy(name, xcb_get_atom_name_name(r), len);
name[len] = '\0';
if (name) {
memcpy(name, xcb_get_atom_name_name(r), len);
name[len] = '\0';
-
- return name;
}
}
free(r);
}
}
}
free(r);
}
- return NULL;
+ return (name);
}
#endif
}
#endif