Skip to content

Commit

Permalink
fix: logger PrintD("") 内存泄漏的问题
Browse files Browse the repository at this point in the history
# man vasprintf

RETURN VALUE
       When successful, these functions return the number of bytes printed, just like sprintf(3).  If memory allocation wasn't possible, or some other error occurs, these functions will return -1, and the contents of strp are undefined.
  • Loading branch information
shinyDeng authored Jan 9, 2024
1 parent e5535a7 commit 7d6eeb8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Util/logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@ void FileChannel::setFileMaxCount(size_t max_count) {
void LoggerWrapper::printLogV(Logger &logger, int level, const char *file, const char *function, int line, const char *fmt, va_list ap) {
LogContextCapture info(logger, (LogLevel) level, file, function, line);
char *str = nullptr;
if (vasprintf(&str, fmt, ap) > 0 && str) {
if (vasprintf(&str, fmt, ap) >= 0 && str) {
info << str;
#ifdef ASAN_USE_DELETE
delete [] str; // 开启asan后,用free会卡死
Expand Down

0 comments on commit 7d6eeb8

Please sign in to comment.