]> git.mdlowis.com Git - projs/tide.git/commitdiff
Fixed a bad memory access in set_path_prop
authorMichael D. Lowis <mike.lowis@gentex.com>
Mon, 19 Mar 2018 18:45:50 +0000 (14:45 -0400)
committerMichael D. Lowis <mike.lowis@gentex.com>
Mon, 19 Mar 2018 18:45:50 +0000 (14:45 -0400)
lib/win.c

index 55fc9e9e7ba88a9516430fee4ef61894d70dfcaa..198e4aeb78f5985b2437c6bc0219a1768a7463d2 100644 (file)
--- a/lib/win.c
+++ b/lib/win.c
@@ -1,3 +1,7 @@
+#define _POSIX_C_SOURCE 200809L
+#define _XOPEN_SOURCE   700
+#include <unistd.h>
+#include <limits.h>
 #include <stdc.h>
 #include <utf.h>
 #include <edit.h>
@@ -67,9 +71,11 @@ static void win_update(int xfd, void* data) {
 }
 
 static void set_path_prop(char* path) {
-    char *abspath = realpath(path, NULL);
+    char pathbuf[PATH_MAX] = {0};
+    if (!path) return;
+    char *abspath = realpath(path, pathbuf);
+    if (!abspath) return;
     x11_prop_set("TIDE_FILE", (!abspath ? "" : abspath));
-    free(abspath);
 }
 
 void win_load(char* path) {