daniel has uploaded this change for review.

View Change

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(-)

git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/21/29121/1
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;


To view, visit change 29121. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I792563696860a3100e95cafdd5fe57511819ef56
Gerrit-Change-Number: 29121
Gerrit-PatchSet: 1
Gerrit-Owner: daniel <dwillmann@sysmocom.de>
Gerrit-MessageType: newchange