digitalocean / prometheus-client-c

A Prometheus Client in C
Other
160 stars 79 forks source link

The function "prom_map_delete" cause “core dump” #37

Open cxyxiaoli opened 3 years ago

cxyxiaoli commented 3 years ago

An abnormal program termination occurred when I called the "prom_map_delete" function. I found that in the following code, the parameter was passed incorrectly. https://github.com/digitalocean/prometheus-client-c/blob/f64fd5998437a89698fb83b7602e75176b1f7416/prom/src/prom_linked_list.c#L155 I changed to the following code, and the problem was solved. https://github.com/digitalocean/prometheus-client-c/blob/f64fd5998437a89698fb83b7602e75176b1f7416/prom/src/prom_map.c#L372 change "prom_map.cpp 372" to : r = prom_linked_list_remove(list, current_node->item);

cxyxiaoli commented 3 years ago

https://github.com/digitalocean/prometheus-client-c/blob/f64fd5998437a89698fb83b7602e75176b1f7416/prom/src/prom_map.c#L372-L376

I think the code for 372 and 375 should be swapped, because the string will be free in the map-node's callback.