Browse code

bb#11364 - convenience_ctx containing uninitialized memory

Kevin Lin authored on 2015/07/29 03:11:02
Showing 1 changed files
... ...
@@ -58,22 +58,22 @@ cli_ctx *convenience_ctx(int fd) {
58 58
     cli_ctx *ctx;
59 59
     struct cl_engine *engine;
60 60
 
61
-    ctx = malloc(sizeof(*ctx));
61
+    ctx = cli_calloc(1, sizeof(cli_ctx));
62 62
     if(!ctx){
63
-	printf("ctx malloc failed\n");
63
+	printf("ctx allocation failed\n");
64 64
         return NULL;
65 65
     }
66 66
 
67 67
     ctx->engine = engine = cl_engine_new();
68 68
     if(!(ctx->engine)){	    
69
-	printf("engine malloc failed\n");
69
+	printf("engine initialization failed\n");
70 70
         free(ctx);
71 71
 	return NULL;
72 72
     }	
73 73
 
74
-    ctx->fmap = cli_malloc(sizeof(struct F_MAP *));
74
+    ctx->fmap = cli_calloc(1, sizeof(struct F_MAP *));
75 75
     if(!(ctx->fmap)){
76
-	printf("fmap malloc failed\n");
76
+	printf("fmap initialization failed\n");
77 77
         free(engine);
78 78
         free(ctx);
79 79
 	return NULL;