]> git.mdlowis.com Git - projs/tide.git/commitdiff
fixed bug in job_finish() which resulted in a use-after-free
authorMichael D. Lowis <mike@mdlowis.com>
Fri, 4 Jan 2019 03:02:09 +0000 (22:02 -0500)
committerMichael D. Lowis <mike@mdlowis.com>
Fri, 4 Jan 2019 03:02:09 +0000 (22:02 -0500)
TODO.md
config.mk
inc/win.h
src/lib/job.c

diff --git a/TODO.md b/TODO.md
index 1bcc5be8a8cc3d4d61eece08355b07b004c41fd1..59eb8a369d07484f189be13ff8b253a3dbab80ef 100644 (file)
--- a/TODO.md
+++ b/TODO.md
@@ -15,7 +15,6 @@
 * tide: should re-register with the registrar when a new registrar is launched
 * tide: Line - Get the current line number(s) containing the selection
 * tide: gap buffer does not handle UTF-8 currently
-* tide: holding cut shortcut will segfault eventually, paste probably as well
 * edit: hangs after launching an empty tide instance then trying to open already open file
 
 ## BACKLOG
@@ -67,4 +66,3 @@ isfile [VALUE]
 findfile [VALUE]
 matches [NAME] [REGEX]
 exec [CMD] [ARGS...]
-
index 1de3ee6e01bd0db51e9016d783dabfc04b7a8319..cb8c7f5248133e23ee496a2f6fbae900c07ca932 100644 (file)
--- a/config.mk
+++ b/config.mk
@@ -20,8 +20,9 @@ CC = cc
 CFLAGS  = -g -MMD $(INCS)
 CFLAGS += --std=c99 -pedantic
 CFLAGS += -Wall -Wextra
-#CFLAGS += -Werror
+CFLAGS += -Werror
 CFLAGS += -Wno-missing-field-initializers -Wno-implicit-fallthrough
+
 # Linker Setup
 LD = $(CC)
 LDFLAGS = $(LIBS) -lX11 -lXft -lfontconfig -lXinerama -lutil -lm
@@ -30,6 +31,10 @@ LDFLAGS = $(LIBS) -lX11 -lXft -lfontconfig -lXinerama -lutil -lm
 AR = ar
 ARFLAGS = rcs
 
+# Enable Sanitizers
+#CFLAGS += -g -fsanitize=address,undefined
+#LDFLAGS += -g -fsanitize=address,undefined
+
 # Set the variables below or set them on the command line to enable the
 # corresponding feature
 DEBUG  = 0
index edfbd1a4d82861c4847514426a199b5c2fbdf014..0aed412f5b04990beb367aa0d62eed2e0d6ecbcb 100644 (file)
--- a/inc/win.h
+++ b/inc/win.h
@@ -129,14 +129,9 @@ void win_init(KeyBinding* bindings);
 void win_title(char* path);
 void win_font(char* font);
 void win_prop_set(char* xname, char* ename, char* value);
-void win_update(int ms);
 void win_loop(void);
 void win_quit(void);
 void win_togglefocus(void);
-void win_syncmouse(void);
-
 View* win_view(WinRegion id);
 Buf* win_buf(WinRegion id);
 bool win_keymodsset(int mask);
-bool win_sel_get(int selid, void(*cbfn)(char*));
-bool win_sel_set(int selid, char* str);
index 104e5ac0c73f3d535f2d05a9b67463fde0580c05..df078c2e9dac9e74443588f9740e2976416d89de 100644 (file)
@@ -55,16 +55,17 @@ static void pipe_write(Job* job) {
     }
 }
 
-static void job_finish(Job* job) {
-    if (job == JobList) {
-        JobList = JobList->next;
+static Job* job_remove(Job* list, Job* job) {
+    if (list == job) {
+        return job->next;
     } else {
-        Job* curr = JobList;
-        while (curr->next && curr->next->fd != job->fd) {
-            curr->next = curr->next->next;
-            curr = curr->next;
-        }
+        list->next = job_remove(list->next, job);
+        return list;
     }
+}
+
+static void job_finish(Job* job) {
+    JobList = job_remove(JobList, job);
     close(job->fd);
     free(job->data);
     free(job);