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

malloc question #190

Closed
RekGRpth opened this issue Jan 17, 2022 · 4 comments
Closed

malloc question #190

RekGRpth opened this issue Jan 17, 2022 · 4 comments
Labels
bug Something isn't working

Comments

@RekGRpth
Copy link

m = (struct message*)malloc(sizeof(struct message));
m->data = malloc(size);
memset(m->data, 0, size);
what happens if malloc returns null?

@RekGRpth RekGRpth added the bug Something isn't working label Jan 17, 2022
@jesperpedersen
Copy link
Collaborator

While pgagroal has a very low memory allocation rate there is def work needed on all error paths - including the one you pointed out.

Likely need a fault injection framework like - https://github.com/jesperpedersen/libfaults - to get through them all; including call sites.

I welcome contributions to both projects within this space !

@RekGRpth
Copy link
Author

try use

cppcheck -j"$(nproc)" --verbose --force --enable=all --suppress=variableScope . 2> check.err

and automate it on test builds

@SudeepRed
Copy link
Contributor

SudeepRed commented Mar 20, 2023

In this case, do we return only the error code, something like if (m == NULL) return MESSAGE_STATUS_ERROR; ?
Do we also need to log the error somewhere?

@jesperpedersen
Copy link
Collaborator

Yeah, we should use a pgagroal_log_fatal()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants