浏览代码

check pointer value

Check if the pointer is NULL
hansipie 10 年之前
父节点
当前提交
8c971d1296
共有 1 个文件被更改,包括 4 次插入0 次删除
  1. 4 0
      src/civetweb.c

+ 4 - 0
src/civetweb.c

@@ -1439,6 +1439,10 @@ static void sockaddr_to_string(char *buf, size_t len, const union usa *usa)
 {
 	buf[0] = '\0';
 
+	if (!usa) {
+		return NULL;
+	}
+	
 	if (usa->sa.sa_family == AF_INET) {
 		getnameinfo(
 		    &usa->sa, sizeof(usa->sin), buf, len, NULL, 0, NI_NUMERICHOST);