[C][Client] Check the pointer before deleting operation to avoid core dump label:"Client C" (#5626)

* [C-libcurl] Check the pointer before deleting operation to avoid core dump

* [C-libcurl] Check the pointer before deleting operation, update sample
This commit is contained in:
Hui Yu
2020-03-24 09:53:01 +08:00
committed by GitHub
parent b3b3941d09
commit f7fe93b8d6
9 changed files with 29 additions and 4 deletions

View File

@@ -88,8 +88,10 @@ void list_iterateThroughListBackward(list_t *list,
}
void list_free(list_t *list) {
list_iterateThroughListForward(list, listEntry_free, NULL);
free(list);
if(list){
list_iterateThroughListForward(list, listEntry_free, NULL);
free(list);
}
}
void list_addElement(list_t *list, void *dataToAddInList) {

View File

@@ -205,6 +205,9 @@ char* {{name}}{{classname}}_ToString({{projectName}}_{{classVarName}}_{{enumName
void {{classname}}_free({{classname}}_t *{{classname}}) {
if(NULL == {{classname}}){
return ;
}
listEntry_t *listEntry;
{{#vars}}
{{^isContainer}}