Skip to contentSkip to conversation

xenstore: Fix memory leak in command 'xenstore rm'

PATCH New Yu Zhiguo 1 participant 1 message Dec 18, 2009

lore
Share & tools
lore

Yu Zhiguo

author
#0 lore raw

PATCH 1/1 xenstore: Fix memory leak in command 'xenstore rm'

When option '-t' is used to do tidy remove, routine xs_directory() will be called in order to check there are brother directories or not. The returned pointer should be passed to free() after this check.

tools/xenstore/xenstore_client.c +4 -2
diff -r 1a911fd65e52 -r 1bd6c2c5e109 tools/xenstore/xenstore_client.c
@@ -343,8 +343,10 @@
                         unsigned int num;
                         char ** list = xs_directory(xsh, xth, p, &num);
 
-                        if (list && num == 0) {
-                            goto again;
+                        if (list) {
+                            free(list);
+                            if (num == 0)
+                                goto again;
                         }
                     }
                 }