[sheepdog] [PATCH v2] Sheepfs: check NULL pointer return of sheepfs_run_cmd function

Ziye Yang ziye.yang at intel.com
Mon Jul 6 11:38:10 CEST 2015


We do not correctly check the NULL pointer value of sheepfs_run_cmd,
it should be fixed.

Signed-off-by: Ziye Yang <ziye.yang at intel.com>
---
 sheepfs/core.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/sheepfs/core.c b/sheepfs/core.c
index 473cbb5..6f246e1 100644
--- a/sheepfs/core.c
+++ b/sheepfs/core.c
@@ -408,8 +408,10 @@ int main(int argc, char **argv)
 		exit(1);
 
 	t = sheepfs_run_cmd("dog");
-	if (t && !strlen(t->buf)) {
+	if (!t || (t && !strlen(t->buf))) {
 		fprintf(stderr, "command dog not found\n");
+		if(t)
+			free(t);
 		exit(1);
 	}
 	strbuf_release(t);



More information about the sheepdog mailing list