Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

va_start and va_end should be in one block of code #154

Open
rockdaboot opened this issue Mar 17, 2018 · 0 comments
Open

va_start and va_end should be in one block of code #154

rockdaboot opened this issue Mar 17, 2018 · 0 comments

Comments

@rockdaboot
Copy link

In printbuf.c, sprintbuf() this piece of code might not compile or work as expected everywhere:

va_start(ap, msg);
if((size = vasprintf(&t, msg, ap)) < 0) { va_end(ap); return -1; }
va_end(ap);

From the man page:

On some systems, va_end contains a closing '}' matching a '{' in va_start, so that both macros must  occur  in the same function, and in a way that allows this.

Should be

va_start(ap, msg);
size = vasprintf(&t, msg, ap);
va_end(ap);
if(size < 0) return -1;

I didn't check if that kind of code is used somewhere - it was just a random encounter.

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

No branches or pull requests

1 participant