neels has submitted this change. ( https://gerrit.osmocom.org/c/libosmocore/+/29121 )
Change subject: use_count: Return if uc is NULL ......................................................................
use_count: Return if uc is NULL
The documentation for osmo_use_count_get_put states the return value is "Negative on range violations or USE_LIST == NULL, the use_cb()'s return value, or 0 on success"
However, the code in _osmo_use_count_get_put doesn't check if uc is NULL - instead it would crash in osmo_use_count_find() where it is dereferenced. Add a check for uc and return -EINVAL if it is NULL.
Change-Id: I792563696860a3100e95cafdd5fe57511819ef56 Related: SYS#5895 --- M src/use_count.c 1 file changed, 2 insertions(+), 0 deletions(-)
Approvals: neels: Looks good to me, approved fixeria: Looks good to me, but someone else must approve dexter: Looks good to me, but someone else must approve Jenkins Builder: Verified
diff --git a/src/use_count.c b/src/use_count.c index 6c52899..9714403 100644 --- a/src/use_count.c +++ b/src/use_count.c @@ -235,6 +235,8 @@ { struct osmo_use_count_entry *e; int32_t old_use_count; + if (!uc) + return -EINVAL; if (!change) return 0;