Skip to content

Commit 90ab94f

Browse files
nordic-krchnashif
authored andcommitted
logging: Do not store module name pointer when strings are stripped
When logging strings are stripped then addresses to log module names are invalid. Do not store that address in the const data structure associated with the logging module to avoid someone accessing it. Store null instead. Signed-off-by: Krzysztof Chruściński <[email protected]>
1 parent a797006 commit 90ab94f

File tree

1 file changed

+2
-1
lines changed
  • include/zephyr/logging

1 file changed

+2
-1
lines changed

include/zephyr/logging/log.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,8 @@ void z_log_vprintk(const char *fmt, va_list ap);
328328
log_source_const_data, \
329329
Z_LOG_ITEM_CONST_DATA(_name)) = \
330330
{ \
331-
.name = COND_CODE_1(CONFIG_LOG_FMT_SECTION, \
331+
.name = IS_ENABLED(LOG_FMT_SECTION_STRIP) ? NULL : \
332+
COND_CODE_1(CONFIG_LOG_FMT_SECTION, \
332333
(UTIL_CAT(_name, _str)), (STRINGIFY(_name))), \
333334
.level = (_level) \
334335
}

0 commit comments

Comments
 (0)