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

Don't use a nonliteral format string in test/fheap.c:begin_test(). #1401

Merged
merged 4 commits into from
Feb 3, 2022

Conversation

gnuoyd
Copy link
Contributor

@gnuoyd gnuoyd commented Jan 28, 2022

No description provided.

HDassert(del_str);
test_desc = (char *)H5MM_malloc(HDstrlen(del_str) + HDstrlen(base_desc));
HDsprintf(test_desc, base_desc, del_str);
size_t test_desc_len = strlen(base_desc) + sizeof(" ") + strlen(del_str);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think this might need an extra +1 for the NUL terminator.

/* Remove half of total objects from heap */
if (tparam->del_dir == FHEAP_DEL_FORWARD)
if (tparam->drain_half == FHEAP_DEL_DRAIN_ALL)
str = H5MM_strdup("(all - forward)");
return "(all - forward)";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm all for removing memory allocations where they aren't really needed!

@gnuoyd
Copy link
Contributor Author

gnuoyd commented Jan 28, 2022 via email

@jhendersonHDF
Copy link
Collaborator

sizeof(" ") includes the NUL terminator of " ". Dave

Ah that's true. I mistakenly read as strlen(" ").

@lrknox lrknox merged commit 856de93 into develop Feb 3, 2022
@gnuoyd gnuoyd deleted the feature/fheap-snprintf branch March 11, 2022 17:07
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

Successfully merging this pull request may close these issues.

3 participants