]> git.sur5r.net Git - i3/i3/commitdiff
Merge pull request #2960 from orestisf1993/next
authorIngo Bürk <admin@airblader.de>
Sun, 17 Sep 2017 10:05:04 +0000 (12:05 +0200)
committerGitHub <noreply@github.com>
Sun, 17 Sep 2017 10:05:04 +0000 (12:05 +0200)
Fix possible errors related to free()

src/randr.c
src/tree.c
src/util.c

index bc7916964356eb75ff760fa0dc07e5546af758da..88cad7c51d5c9df1c2f32f44463665da4c9b31cd 100644 (file)
@@ -1048,8 +1048,8 @@ void randr_init(int *event_base, const bool disable_randr15) {
         xcb_randr_query_version_reply(
             conn, xcb_randr_query_version(conn, XCB_RANDR_MAJOR_VERSION, XCB_RANDR_MINOR_VERSION), &err);
     if (err != NULL) {
-        free(err);
         ELOG("Could not query RandR version: X11 error code %d\n", err->error_code);
+        free(err);
         fallback_to_root_output();
         return;
     }
index b3d2ce93c04408e3d8e6b87318b2fefa018baccb..7f46658313ae979bd5e735845e336ddaaa1288f6 100644 (file)
@@ -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. */
index cd5ee03e49e607f689f265a95bcb9acc64cbdbcc..ba0969c729674aabe3dd04a0ce9614803514f4f7 100644 (file)
@@ -501,7 +501,7 @@ ssize_t slurp(const char *path, char **buf) {
     fclose(f);
     if ((ssize_t)n != stbuf.st_size) {
         ELOG("File \"%s\" could not be read entirely: got %zd, want %zd\n", path, n, stbuf.st_size);
-        free(buf);
+        free(*buf);
         *buf = NULL;
         return -1;
     }