Skip to content

StRoot/StUtilities/StMessage: fix regression from using the proper std::ostringstream::str#168

Merged
plexoos merged 3 commits intostar-bnl:mainfrom
veprbl:pr/fix_165
Oct 11, 2021
Merged

StRoot/StUtilities/StMessage: fix regression from using the proper std::ostringstream::str#168
plexoos merged 3 commits intostar-bnl:mainfrom
veprbl:pr/fix_165

Conversation

@veprbl
Copy link
Copy Markdown
Member

@veprbl veprbl commented Oct 8, 2021

Resolves: #165
Closes: #166

This partially reverts fdb863a ('Initialize and test ostrstream buffer sizes (support for gcc before 3.2)')
@veprbl veprbl requested a review from genevb as a code owner October 8, 2021 10:22
@veprbl
Copy link
Copy Markdown
Member Author

veprbl commented Oct 8, 2021

Basically the regression is due to change in the meaning of the following line:

myout << messBuffer.str();

Previously it was printing a NULL-terminated string from a char* and now it works with a string of a know length, an std::string.

@veprbl veprbl changed the title StRoot/StUtilities: don't add padding to message buffers StRoot/StUtilities/StMessage: fix regression from using the proper std::ostringstream::str Oct 8, 2021
Copy link
Copy Markdown
Contributor

@genevb genevb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not really paying close attention to the modifications being made to the message management, but I see that github requires me to at least submit a comment. Doing so here so that I'm not an obstacle to the effort.

The .str().c_str() is safe to use within a single expression, but
saving a pointer would be an UB.

This issue was found using valgrind.
@plexoos plexoos merged commit 4d1d350 into star-bnl:main Oct 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Garbage in the output produced by StChain

3 participants