[Asterisk-code-review] res_geoloc: fix NULL pointer dereference bug (asterisk[18])
Alexandre Fournier
asteriskteam at digium.com
Mon Dec 12 08:48:59 CST 2022
Alexandre Fournier has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/19695 )
Change subject: res_geoloc: fix NULL pointer dereference bug
......................................................................
res_geoloc: fix NULL pointer dereference bug
The `ast_geoloc_datastore_add_eprofile` function does not return 0 on
success, it returns the size of the underlying datastore. This means
that the datastore will be freed and its pointer set to NULL when no
error occured at all.
ASTERISK-30346
Change-Id: Iea9b209bd1244cc57b903b9496cb680c356e4bb9
---
M res/res_geolocation/geoloc_datastore.c
1 file changed, 18 insertions(+), 2 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/95/19695/1
diff --git a/res/res_geolocation/geoloc_datastore.c b/res/res_geolocation/geoloc_datastore.c
index 040a9bd..4e7a85e 100644
--- a/res/res_geolocation/geoloc_datastore.c
+++ b/res/res_geolocation/geoloc_datastore.c
@@ -255,7 +255,7 @@
}
rc = ast_geoloc_datastore_add_eprofile(ds, eprofile);
- if (rc != 0) {
+ if (rc <= 0) {
ast_datastore_free(ds);
ds = NULL;
}
@@ -297,7 +297,7 @@
rc = ast_geoloc_datastore_add_eprofile(ds, eprofile);
ao2_ref(eprofile, -1);
- if (rc != 0) {
+ if (rc <= 0) {
ast_datastore_free(ds);
ds = NULL;
}
--
To view, visit https://gerrit.asterisk.org/c/asterisk/+/19695
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 18
Gerrit-Change-Id: Iea9b209bd1244cc57b903b9496cb680c356e4bb9
Gerrit-Change-Number: 19695
Gerrit-PatchSet: 1
Gerrit-Owner: Alexandre Fournier <afournier at wazo.io>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20221212/1021afb6/attachment.html>
More information about the asterisk-code-review
mailing list