nginx-upsync-module icon indicating copy to clipboard operation
nginx-upsync-module copied to clipboard

ngx_http_upsync_etcd_parse_json memory leak?

Open kuaikuai opened this issue 7 years ago • 3 comments

    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释放内存。是否需要释放?

kuaikuai avatar Oct 18 '18 02:10 kuaikuai

It's NULL?

xiaokai-wang avatar Oct 25 '18 15:10 xiaokai-wang

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

lvphpwb avatar Apr 28 '21 03:04 lvphpwb

@lvphpwb Do you have a test? Thanks.

xiaokai-wang avatar Apr 29 '21 16:04 xiaokai-wang