From: Orestis Floros Date: Sat, 16 Sep 2017 20:53:31 +0000 (+0300) Subject: Prevent freeing of uninitialized pointer X-Git-Tag: 4.15~80^2~2 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=205dd7609695f3808f2cff0167ec836a7d66ec17;p=i3%2Fi3 Prevent freeing of uninitialized pointer > variable 'buf' is used uninitialized whenever 'if' condition is true Note: freeing a NULL pointer is fine. --- diff --git a/src/tree.c b/src/tree.c index b3d2ce93..7f466583 100644 --- a/src/tree.c +++ b/src/tree.c @@ -66,13 +66,13 @@ static Con *_create___i3(void) { bool tree_restore(const char *path, xcb_get_geometry_reply_t *geometry) { bool result = false; char *globbed = resolve_tilde(path); + char *buf = NULL; if (!path_exists(globbed)) { LOG("%s does not exist, not restoring tree\n", globbed); goto out; } - char *buf = NULL; ssize_t len; if ((len = slurp(globbed, &buf)) < 0) { /* slurp already logged an error. */