Skip to content

[zmq] Call va_end() on va_start()ed args.#10056

Merged
laanwj merged 1 commit intobitcoin:masterfrom
kallewoof:fix-zmqpublishnotifier-va-end
Mar 27, 2017
Merged

[zmq] Call va_end() on va_start()ed args.#10056
laanwj merged 1 commit intobitcoin:masterfrom
kallewoof:fix-zmqpublishnotifier-va-end

Conversation

@kallewoof
Copy link
Copy Markdown
Contributor

@kallewoof kallewoof commented Mar 22, 2017

A function that invokes va_start, shall also invoke va_end before it returns.
(http://www.cplusplus.com/reference/cstdarg/va_start/)

If there is no corresponding call to va_start or va_copy, or if va_end is not called before a function that calls va_start or va_copy returns, the behavior is undefined.
http://en.cppreference.com/w/cpp/utility/variadic/va_end

@gmaxwell
Copy link
Copy Markdown
Contributor

gmaxwell commented Mar 23, 2017

ugh. see this is why we need to test on sparc. :P

(On sparc forgetting to va_end will instantly corrupt the stack.)

@laanwj
Copy link
Copy Markdown
Member

laanwj commented Mar 23, 2017

utACK, haven't checked though whether this covers all cases.

@paveljanik
Copy link
Copy Markdown
Contributor

utACK 5ba61f0

@laanwj It covers all returns there.

@jonasschnelli
Copy link
Copy Markdown
Contributor

utACK 5ba61f0.
I've check all the usages of va_list (va_start, va_copy) and expect of the ones covered in this PR we are good.

@laanwj
Copy link
Copy Markdown
Member

laanwj commented Mar 23, 2017

ugh. see this is why we need to test of sparc. :P

That reminds me, ideally we'd use typesafe c++11 variadic templates instead of C varags legacy mess.

@laanwj laanwj merged commit 5ba61f0 into bitcoin:master Mar 27, 2017
laanwj added a commit that referenced this pull request Mar 27, 2017
5ba61f0 [zmq] Call va_end() on va_start()ed args. (Karl-Johan Alm)

Tree-SHA512: fbd3a0c29308ca9607f362f14fa7ea9c949a3f25dc09a349fe3b3ffd316b573c86778e29d3b9d55c684571eacae50aca90bb872e2e5489818d0af8310511fe79
@kallewoof kallewoof deleted the fix-zmqpublishnotifier-va-end branch March 13, 2018 12:39
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request May 21, 2019
5ba61f0 [zmq] Call va_end() on va_start()ed args. (Karl-Johan Alm)

Tree-SHA512: fbd3a0c29308ca9607f362f14fa7ea9c949a3f25dc09a349fe3b3ffd316b573c86778e29d3b9d55c684571eacae50aca90bb872e2e5489818d0af8310511fe79
DeckerSU added a commit to DeckerSU/komodo that referenced this pull request Jan 22, 2020
DeckerSU added a commit to DeckerSU/KomodoOcean that referenced this pull request Jan 23, 2020
Fair-Exchange pushed a commit to Fair-Exchange/SafecoinClassic that referenced this pull request May 16, 2020
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants