Skip to content

Commit

Permalink
fix long message causing program exit at exception. (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
kejxu authored and dirk-thomas committed Jan 26, 2019
1 parent ea94990 commit 93da95b
Showing 1 changed file with 0 additions and 13 deletions.
13 changes: 0 additions & 13 deletions src/rosconsole/rosconsole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -461,27 +461,14 @@ void initialize()

void vformatToBuffer(boost::shared_array<char>& buffer, size_t& buffer_size, const char* fmt, va_list args)
{
#ifdef _MSC_VER
va_list arg_copy = args; // dangerous?
#else
va_list arg_copy;
va_copy(arg_copy, args);
#endif
#ifdef _MSC_VER
size_t total = vsnprintf_s(buffer.get(), buffer_size, buffer_size, fmt, args);
#else
size_t total = vsnprintf(buffer.get(), buffer_size, fmt, args);
#endif
if (total >= buffer_size)
{
buffer_size = total + 1;
buffer.reset(new char[buffer_size]);

#ifdef _MSC_VER
vsnprintf_s(buffer.get(), buffer_size, buffer_size, fmt, arg_copy);
#else
vsnprintf(buffer.get(), buffer_size, fmt, arg_copy);
#endif
}
va_end(arg_copy);
}
Expand Down

0 comments on commit 93da95b

Please sign in to comment.