Code: Select all
char *string = NULL;
ESP_LOGD( TAG, "*** crash here %s", string );
Code: Select all
char *string = NULL;
ESP_LOGD( TAG, "*** crash here %s", string );
I would hazard to guess that the the esp_log_write function (used by the ESP_LOG macro) uses the standard vsnprintf and unless they change that any other solution would be non-trivial.ataweg wrote:The following code snipplet results in a program crash:Since the ESP_LOG * functions are often used for debugging, it is more than annoying when these functions themselves crash, because the parameters are not well defined.Code: Select all
char *string = NULL; ESP_LOGD( TAG, "*** crash here %s", string );
To wrap it up, it's to save space.7.1.4 Use of library functions
1 Each of the following statements applies unless explicitly stated otherwise in the detailed descriptions that follow: If an argument to a function has an invalid value (such as a value outside the domain of the function, or a pointer outside the address space of the program, or a null pointer,or a pointer to non-modifiable storage when the corresponding parameter is not const-qualified) or a type (after promotion) not expected by a function with variable number of arguments, the behavior is undefined.
Code: Select all
#define SS(s) (s!=NULL?s:"") // Safe strings. Check string for NULL
Code: Select all
#define SS(s) (s!=NULL?s:"<NULL>") // Safe strings. Check string for NULL
Code: Select all
char *string = NULL;
ESP_LOGD( TAG, "*** crash here %s", SS(string) );
Users browsing this forum: No registered users and 37 guests