diff options
author | Dimitri van Heesch <doxygen@gmail.com> | 2019-05-07 08:32:06 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-07 08:32:06 (GMT) |
commit | 4ce1a96afcd279eae6caa71f9ee3cdbc3d4aa773 (patch) | |
tree | b1235eb98bff3ce10458fabb1f8df2f8407aedd9 /src | |
parent | 1029f8a7410f99d844005a54211b015188b895f7 (diff) | |
parent | 2d46a052563c1d362bfe4fa3c8fac1a258ce4cc2 (diff) | |
download | Doxygen-4ce1a96afcd279eae6caa71f9ee3cdbc3d4aa773.zip Doxygen-4ce1a96afcd279eae6caa71f9ee3cdbc3d4aa773.tar.gz Doxygen-4ce1a96afcd279eae6caa71f9ee3cdbc3d4aa773.tar.bz2 |
Merge pull request #6963 from albert-github/feature/bug_truncated_warning
Truncated warning message
Diffstat (limited to 'src')
-rw-r--r-- | src/message.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/message.cpp b/src/message.cpp index 2f3a06f..2e3e41a 100644 --- a/src/message.cpp +++ b/src/message.cpp @@ -167,17 +167,25 @@ static void format_warn(const char *file,int line,const char *text) static void do_warn(bool enabled, const char *file, int line, const char *prefix, const char *fmt, va_list args) { if (!enabled) return; // warning type disabled - const int bufSize = 40960; - char text[bufSize]; int l=0; if (prefix) { - qstrncpy(text,prefix,bufSize); l=strlen(prefix); } + // determine needed buffersize based on: + // format + arguments + // prefix + // 1 position for `\0` + int bufSize = vsnprintf(NULL, 0, fmt, args) + l + 1; + char *text = (char *)malloc(sizeof(char) * bufSize); + if (prefix) + { + qstrncpy(text,prefix,bufSize); + } vsnprintf(text+l, bufSize-l, fmt, args); text[bufSize-1]='\0'; format_warn(file,line,text); + free(text); } void warn(const char *file,int line,const char *fmt, ...) |