Skip to content

Commit

Permalink
Prevent access after free of trace messages
Browse files Browse the repository at this point in the history
Add a GetNextSeqNum() function and call it to set the sequence
number in the trace message before calling TraceWrite().

Change-Id: I232e1134f711f534c166c18357986b8d1e692d15
Closes-Bug: #1602899
  • Loading branch information
Megh Bhatt committed Jul 28, 2016
1 parent 7695497 commit de7cdad
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion compiler/generate/t_cpp_generator.cc
Expand Up @@ -4714,8 +4714,9 @@ void t_cpp_generator::generate_sandesh_trace(ofstream& out,
generate_sandesh_no_static_const_string_function(tsandesh, false, false, false, false, true) <<
";" << endl;
out << indent() << creator_name << "->set_category(trace_buf->Name());" << endl;
out << indent() << "uint32_t seqnum = trace_buf->TraceWrite(" << creator_name << ");" << endl;
out << indent() << "uint32_t seqnum(trace_buf->GetNextSeqNum());" << endl;
out << indent() << creator_name << "->set_seqnum(seqnum);" << endl;
out << indent() << "trace_buf->TraceWrite(" << creator_name << ");" << endl;
out << indent() << "if ((IsLocalLoggingEnabled() && IsTracePrintEnabled()) || IsUnitTest()) " << creator_name << "->Log();" << endl;
indent_down();
out << indent() << "}" <<endl;
Expand Down

0 comments on commit de7cdad

Please sign in to comment.