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

Memory not freed in time when debug_print is set to verbose #50

Closed
sherlockcpp opened this issue Apr 5, 2020 · 1 comment
Closed

Memory not freed in time when debug_print is set to verbose #50

sherlockcpp opened this issue Apr 5, 2020 · 1 comment

Comments

@sherlockcpp
Copy link
Contributor

Hi
I found some Memory not freed in time when debug_print is set to verbose
in function restrict_indexes()

when debug_level > 0 , buf malloc 1024 bytes

	if (debug_level > 0)
		initStringInfo(&buf);

at the end of restrict_indexes() , buf.data is freed only if debug_level = 1.
I think buf.data is not freed in time when debug_level is 2 or 3.
[ps. After my check, is does not cause memleak]

	if (debug_level == 1)
	{
		initStringInfo(&rel_buf);
                ...
		pfree(buf.data);
		pfree(rel_buf.data);
	}

I think a new if branch can be create to free buf.data, like the following;

	if (debug_level == 1)
	{
		initStringInfo(&rel_buf);
                ...
		pfree(rel_buf.data);
	}

	if (debug_level > 0)
		pfree(buf.data);
@horiguti
Copy link
Contributor

It is already fixed at master. but don't be so nervous about that:p The memory will be freed up at the end of query. In some sense the pfree is not required at all.
That being said it is not neat that the code behaves differently for subtle conditions.
I committed that change in the PG13 branch in the repo.

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

2 participants