[sheepdog] [PATCH v1 2/2] sheepfs: free memory of strbuf 't'

Robin Dong robin.k.dong at gmail.com
Thu Mar 6 07:10:37 CET 2014


From: Robin Dong <sanbai at taobao.com>

Variable 't' is allocated by sheepfs_run_cmd() and should be released
after using it.

Signed-off-by: Robin Dong <sanbai at taobao.com>
---
 sheepfs/core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sheepfs/core.c b/sheepfs/core.c
index 03172fd..f5ee7b2 100644
--- a/sheepfs/core.c
+++ b/sheepfs/core.c
@@ -392,11 +392,12 @@ int main(int argc, char **argv)
 		exit(1);
 
 	t = sheepfs_run_cmd("dog");
-	if (!strlen(t->buf)) {
+	if (t && !strlen(t->buf)) {
 		fprintf(stderr, "command dog not found\n");
 		exit(1);
 	}
 	strbuf_release(t);
+	free(t);
 
 	if (optind != argc)
 		dir = argv[optind];
-- 
1.7.12.4




More information about the sheepdog mailing list