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

lib/gis: Close va_list if erroring out early in debug module #4702

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ymdatta
Copy link
Contributor

@ymdatta ymdatta commented Nov 14, 2024

Even though, the defined va_list will not be used anywhere, it's a good practice to close it as not doing so leads to undefined behavior.

This was found using cppcheck tool.

Even though, the defined `va_list` will not be used anywhere, it's
a good practice to close it as not doing so leads to undefined
behavior.

This was found using cppcheck tool.

Signed-off-by: Mohan Yelugoti <[email protected]>
@github-actions github-actions bot added C Related code is in C libraries labels Nov 14, 2024
@metzm
Copy link
Contributor

metzm commented Nov 19, 2024

Start ap as late as possible and close it as early as possible ?

        va_start(ap, msg);
        vfprintf(fd, msg, ap);
        va_end(ap);

i.e. move va_start() and va_end() to be directly around vfprintf()

See also error.c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C Related code is in C libraries
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants