From 9c133d19e827fb03adc31f1f5170eb815beb6dcd Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Mon, 19 Mar 2018 14:45:50 -0400 Subject: [PATCH] Fixed a bad memory access in set_path_prop --- lib/win.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/win.c b/lib/win.c index 55fc9e9..198e4ae 100644 --- a/lib/win.c +++ b/lib/win.c @@ -1,3 +1,7 @@ +#define _POSIX_C_SOURCE 200809L +#define _XOPEN_SOURCE 700 +#include +#include #include #include #include @@ -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) { -- 2.49.0