-
Notifications
You must be signed in to change notification settings - Fork 214
Conversation
notroj
commented
Oct 1, 2024
With APR pools, the accepted coding style is to assume apr_palloc() never fails - applications can and install an abort function using apr_pool_create_ex() which is invoked if the underlying memory allocation ever fails.
With APR pools, the accepted coding style is to assume
apr_palloc()never fails - applications can and install an abort function usingapr_pool_create_ex()which is invoked if the underlying memory allocation ever fails.
Thank you for your kind reply and explanation!
I also thought the assumption is apr_palloc() never fails. However, I made the PR because I found some code snippets in the repo that indeed check for the possible null pointers.
For example:
apr/threadproc/netware/threadpriv.c
Lines 25 to 27 in 4283c6a
Lines 71 to 73 in 4283c6a
So I thought it might be good to follow a consistent assumption?
I must admit that I didn't have experience contributing to the APR repo before. My apologies if my understanding is inaccurate, and thank you again for your time!
notroj
commented
Feb 14, 2025
You're right that not all APR code follows the convention, unfortunately.
Uh oh!
There was an error while loading. Please reload this page.
apr_pallocmay return NULL pointer. It may trigger undefined behavior in later usage. For example, passing a null pointer tomemcpymay trigger undefined behavior. Thus it is better to check for NULL.