-
-
Notifications
You must be signed in to change notification settings - Fork 326
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
g.gisenv: Fix Resource Leak issue in main.c #4966
base: main
Are you sure you want to change the base?
Conversation
@nilason won't the G_free directly work here? |
@@ -224,6 +225,7 @@ char *parse_variable(const char *v_name, char **value) | |||
G_verbose_message(_("GRASS variable must be uppercase. Using '%s'."), | |||
u_name); | |||
} | |||
G_free(name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that you should also add a G_free
at line 218 before the G_fatal_error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It wouldn't be bad, but introduce unnecessary code. G_fatal_error
will print an error message and exit
the process. Thus, in-memory will be freed safely and quickly by the system.
Not quite sure what you mean. |
If you mean |
I used G_free() directly but still it failed. |
I now see you mean the tests are failing. The reason wasn't obvious to me at first. This may be a good exercise :). |
The parse_variable function parses a string such as "VAR=value", separating the variable name (VAR) and value (value). Based on your hint I updated the function and tested locally with following testcases Input with only a variable (no =): Input with an empty value: All of them were as expected. It passed on my local windows machine |
This pull request fixes issue identified by Coverity Scan (CID : 1207681)
Used G_free() to fix this issue.