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

Resource leaks #589

Closed
ryancaicse opened this issue Dec 21, 2021 · 2 comments
Closed

Resource leaks #589

ryancaicse opened this issue Dec 21, 2021 · 2 comments

Comments

@ryancaicse
Copy link
Contributor

fclose(fp); should be put before Line 44?

FILE *fp;
char *data = NULL;
if ((fp = fopen(path, "rb")) == NULL) {
} else if (fseek(fp, 0, SEEK_END) != 0) {
fclose(fp);
} else {
*size = ftell(fp);
data = (char *) malloc(*size + 1);
if (data != NULL) {
fseek(fp, 0, SEEK_SET); /* Some platforms might not have rewind(), Oo */
if (fread(data, 1, *size, fp) != *size) {
free(data);
return NULL;
}
data[*size] = '\0';
}
fclose(fp);

@cpq
Copy link
Member

cpq commented Dec 21, 2021

Yes, please send a PR

@rojer
Copy link
Collaborator

rojer commented Jan 5, 2022

fixed by #591

@rojer rojer closed this as completed Jan 5, 2022
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