logging: prevent of NULL pointer comparison
Add prevent dereference NULL in strcmp
@@ -359,8 +359,9 @@ void z_log_runtime_filters_init(void)
int log_source_id_get(const char *name)
{
for (int i = 0; i < log_src_cnt_get(Z_LOG_LOCAL_DOMAIN_ID); i++) {
- if (strcmp(log_source_name_get(Z_LOG_LOCAL_DOMAIN_ID, i),
- name) == 0) {
+ const char *sname = log_source_name_get(Z_LOG_LOCAL_DOMAIN_ID, i);
+
+ if ((sname != NULL) && (strcmp(sname, name) == 0)) {
return i;
}
}
