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

A suspicious memory leak error occured in tig/src/argv.c. #839

Closed
QiAnXinCodeSafe opened this issue Jun 13, 2018 · 4 comments
Closed

A suspicious memory leak error occured in tig/src/argv.c. #839

QiAnXinCodeSafe opened this issue Jun 13, 2018 · 4 comments

Comments

@QiAnXinCodeSafe
Copy link

This is 360 CodeSafe Team, we found a suspicious memory leak occured in tig/src/argv.c. See

tig/src/argv.c

Line 182 in f49fc7c

env = strdup(env);
, strdup(env) will allocate memory and assign the memory adderss to env, however there is no free() action on env. So memory leak will occur at the end of function argv_from_env().

	if (env && *env)
		env = strdup(env);
	return !env || argv_from_string(argv, &argc, env);

Since I'm unfamiliar with tig, please forgive me if there is anything
wrong with my description.

Qihoo360 CodeSafe Team

@ideal
Copy link
Contributor

ideal commented Jun 22, 2018

Seems that need to be freed after call of argv_from_string().

@QiAnXinCodeSafe
Copy link
Author

@ideal if I didn't miss something, I also think it deserve a fix. I don't know if jonas was intentionally designed to do this, or just ignored the memory release action.

@jonas
Copy link
Owner

jonas commented Jun 25, 2018

The method is used in one place and should not be freed. It would probably be better to just inline the code.

@QiAnXinCodeSafe
Copy link
Author

QiAnXinCodeSafe commented Jun 25, 2018

Hmm, I see. Thank you for your explanation, jonas, it seems that there will be no practical impact.

@jonas jonas closed this as completed in b405c6a Jul 8, 2018
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

3 participants