浏览代码

Check ctx before use

hansipie 10 年之前
父节点
当前提交
28fd30dc59
共有 1 个文件被更改,包括 8 次插入0 次删除
  1. 8 0
      src/civetweb.c

+ 8 - 0
src/civetweb.c

@@ -2942,6 +2942,10 @@ static int push(struct mg_context *ctx,
 		clock_gettime(CLOCK_MONOTONIC, &start);
 	}
 
+	if (ctx == NULL){
+		return -1;
+	}
+
 	do {
 
 #ifndef NO_SSL
@@ -2991,6 +2995,10 @@ static int64_t push_all(struct mg_context *ctx,
 	double timeout = -1.0;
 	int64_t n, nwritten = 0;
 
+	if (ctx == NULL){
+		return -1;
+	}
+
 	if (ctx->config[REQUEST_TIMEOUT]) {
 		timeout = atoi(ctx->config[REQUEST_TIMEOUT]) / 1000.0;
 	}