Dears,
size = vsprintf(NULL, format, paramList); is not NULL dereference but standard way how to get final string size.
#include <stdarg.h> #include <stdio.h> int string::printf(const char* format, ...) { va_list paramList; va_start(paramList, format); #ifdef _HAVE_VSNPRINTF size = vsnprintf(0, 0, format, paramList); #else size = vsprintf(NULL, format, paramList); #endif if(size) { resize(size); #ifdef _HAVE_VSNPRINTF size = vsnprintf(ch, maxlen, format, paramList); #else size = vsprintf(ch, format, paramList); #endif } else erase(); va_end(paramList); return size; }
Jara
sorry for late reply. I fail to reproduce with latest cppcheck. If you still see this false positive then please feel free to ping..
Log in to post a comment.
Dears,
size = vsprintf(NULL, format, paramList);
is not NULL dereference but standard way how to get final string size.
Jara
Last edit: Daniel Marjamäki 2021-01-05
sorry for late reply. I fail to reproduce with latest cppcheck. If you still see this false positive then please feel free to ping..