aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2018-02-11 11:37:06 -0500
committerGitHub <noreply@github.com>2018-02-11 11:37:06 -0500
commit4a76d06f33964fee12682a9cd7066d1776c71024 (patch)
tree3ae8f4c736c978ec5b9e29cfbcab0de8db058198
parenta571506d0e3abae0a8fe05a186cb5a33623bdf94 (diff)
parentaa15629f17d65d45c02c30b6392e74d752b520b3 (diff)
downloadsway-4a76d06f33964fee12682a9cd7066d1776c71024.zip
sway-4a76d06f33964fee12682a9cd7066d1776c71024.tar.gz
sway-4a76d06f33964fee12682a9cd7066d1776c71024.tar.bz2
Merge pull request #1591 from dlrobertson/fix_mem_errors
Fix memory errors
-rw-r--r--common/readline.c2
-rw-r--r--sway/handlers.c2
-rw-r--r--sway/ipc-server.c8
3 files changed, 9 insertions, 3 deletions
diff --git a/common/readline.c b/common/readline.c
index cc40a2c..d35ba73 100644
--- a/common/readline.c
+++ b/common/readline.c
@@ -36,7 +36,7 @@ char *read_line(FILE *file) {
}
string[length++] = c;
}
- if (length + 1 == size) {
+ if (length + 1 >= size) {
char *new_string = realloc(string, length + 1);
if (!new_string) {
free(string);
diff --git a/sway/handlers.c b/sway/handlers.c
index d3d5913..616a01b 100644
--- a/sway/handlers.c
+++ b/sway/handlers.c
@@ -484,6 +484,8 @@ static bool handle_view_created(wlc_handle handle) {
// refocus in-between command lists
set_focused_container(newview);
}
+ // Make sure to free the list_t returned by criteria_for.
+ list_free(criteria);
swayc_t *workspace = swayc_parent_by_type(focused, C_WORKSPACE);
if (workspace && workspace->fullscreen) {
set_focused_container(workspace->fullscreen);
diff --git a/sway/ipc-server.c b/sway/ipc-server.c
index e10445c..6b704e4 100644
--- a/sway/ipc-server.c
+++ b/sway/ipc-server.c
@@ -1127,7 +1127,7 @@ static void ipc_event_binding(json_object *sb_obj) {
json_object *obj = json_object_new_object();
json_object_object_add(obj, "change", json_object_new_string("run"));
// sb_obj gets owned by the temporary json_object, too.
- json_object_object_add(obj, "binding", json_object_get(sb_obj));
+ json_object_object_add(obj, "binding", sb_obj);
const char *json_string = json_object_to_json_string(obj);
ipc_send_event(json_string, IPC_EVENT_BINDING);
@@ -1171,9 +1171,13 @@ void ipc_event_binding_keyboard(struct sway_binding *sb) {
keysym = *(uint32_t *)sb->keys->items[i];
if (xkb_keysym_get_name(keysym, buffer, 64) > 0) {
json_object *str = json_object_new_string(buffer);
- json_object_array_add(symbols, str);
if (i == 0) {
+ // str is owned by both symbol and symbols. Make sure
+ // to bump the ref count.
+ json_object_array_add(symbols, json_object_get(str));
symbol = str;
+ } else {
+ json_object_array_add(symbols, str);
}
}
}