Skip to content

Commit 89be07a

Browse files
committed
Pedantic vsnprintf error checking
1 parent 28bdbbe commit 89be07a

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/njs/src/njsMessages.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,11 @@ string NJSMessages::getErrorMsg ( NJSErrorType err, ... )
7272
{
7373
// print all specified arguments
7474
va_start (vlist, err);
75-
vsnprintf (msg, MAX_ERROR_MSG_LEN, errMsg[err-1], vlist);
75+
if ( vsnprintf (msg, MAX_ERROR_MSG_LEN, errMsg[err-1], vlist) <= 0)
76+
{
77+
msg[0] = 0;
78+
}
79+
7680
va_end (vlist);
7781

7882
str = msg;

0 commit comments

Comments
 (0)