• M
    Fix printing of empty string pointers · 8222e9b8
    Max Bruckner 提交于
    Once the check if str is NULL is reached, str has already been
    derereferenced in the for loop, so in the case that the if clause would
    be entered, the program has already crashed due to a null pointer
    dereference.
    
    By checking the content of str before dereferencing, the code in the if
    clause is actually useful.
    
    for (ptr=str;*ptr;ptr++) flag|=((*ptr>0 && *ptr<32)||(*ptr=='\"')||(*ptr=='\\'))?1:0;
    
    ...
    
    if (!str)
    ...
    8222e9b8
cJSON.c 27.4 KB