-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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 null pointer may cause a segmentation fault. #865
Comments
It's a test. If there is a null pointer segmentation fault, the test fails. If the allocation is checked for failure, and failure is detected, the test fails ... more cleanly. It's probably not worth the more verbose code for this extremely unlikely case which will be caught anyway. |
Yes, I am glad to submit a patch. Besides, I agree with @ploxiln too. We should terminate the test with an error message if the allocation is checked for failure. But we can't guarantee that everyone will do this when calling event_add(). So, I prefer to add NULL check. :) |
We shouldn't, this is not our job, |
Fixes: libevent#865 (cherry picked from commit 101fbe3)
The main function of the sample/signal-test.c file is defined as follows:
It is possible to have a null pointer returned in the event_new()。
Once a null pointer is passed in, event_add() does't have a null protection, it will cause a segmentation fault.
Therefore, I came up with two ways to improve it.:
The above is just my suggestion, do you have any other else?
The text was updated successfully, but these errors were encountered: