weibocom / nginx-upsync-module

For http protocol. nginx-upsync-module, sync upstreams from consul or etcd and so on, dynamiclly modify backend-servers attributes(weight, max_fails, down...), needn't reload nginx
1.83k stars 391 forks source link

ngx_http_upsync_etcd_parse_json memory leak? #233

Open kuaikuai opened 6 years ago

kuaikuai commented 6 years ago
    temp0 = cJSON_GetObjectItem(server_next, "value");
    if (temp0 != NULL && ngx_strlen(temp0->valuestring) != 0) {

        cJSON *sub_attribute = cJSON_Parse((char *)temp0->valuestring);
        if (sub_attribute == NULL) {
            ngx_log_error(NGX_LOG_ERR, ngx_cycle->log, 0,
                          "upsync_parse_json: \'%s\' is invalid", 
                          temp0->valuestring);
            continue;
        }

sub_attribute没有调用cJSON_Delete释放内存。是否需要释放?

xiaokai-wang commented 6 years ago

It's NULL?

lvphpwb commented 3 years ago

确实是有内存泄漏 cJSON_Delete后内存正常

xiaokai-wang commented 3 years ago

@lvphpwb Do you have a test? Thanks.