From 662df4ca26cfe9603a2824d31131324c30c8b6bd Mon Sep 17 00:00:00 2001 From: Tomi Valkeinen Date: Mon, 29 Aug 2022 11:44:44 +0300 Subject: libcamera: base: log: Fix use of freed name LogCategory just stores the char * that was given to it in the constructor, i.e. it refers to memory "outside" LogCategory. If the LogCategory is defined in a .so that is unloaded, then it leads to the LogCategory pointing to freed memory, causing a crash. Fix this by taking a copy of the name by using a std::string instead of just storing the pointer. Signed-off-by: Tomi Valkeinen Reviewed-by: Laurent Pinchart Reviewed-by: Kieran Bingham Signed-off-by: Laurent Pinchart --- src/libcamera/base/log.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/libcamera/base/log.cpp b/src/libcamera/base/log.cpp index 5c359a22..a4a5b452 100644 --- a/src/libcamera/base/log.cpp +++ b/src/libcamera/base/log.cpp @@ -568,7 +568,7 @@ void Logger::logSetLevel(const char *category, const char *level) return; for (LogCategory *c : categories_) { - if (!strcmp(c->name(), category)) { + if (c->name() == category) { c->setSeverity(severity); break; } -- cgit v1.2.1