]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
res_geoloc: fix NULL pointer dereference bug
authorAlexandre Fournier <afournier@wazo.io>
Fri, 9 Dec 2022 19:37:13 +0000 (14:37 -0500)
committerGeorge Joseph <gjoseph@digium.com>
Tue, 13 Dec 2022 15:32:10 +0000 (10:32 -0500)
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

res/res_geolocation/geoloc_datastore.c

index 040a9bdcdb3f4950fae2694224c1a94985711bd4..4e7a85e8f1a4ddd7ed60dd590e5f01a6aa2c7c6f 100644 (file)
@@ -255,7 +255,7 @@ struct ast_datastore *ast_geoloc_datastore_create_from_eprofile(
        }
 
        rc = ast_geoloc_datastore_add_eprofile(ds, eprofile);
-       if (rc != 0) {
+       if (rc <= 0) {
                ast_datastore_free(ds);
                ds = NULL;
        }
@@ -297,7 +297,7 @@ struct ast_datastore *ast_geoloc_datastore_create_from_profile_name(const char *
 
        rc = ast_geoloc_datastore_add_eprofile(ds, eprofile);
        ao2_ref(eprofile, -1);
-       if (rc != 0) {
+       if (rc <= 0) {
                ast_datastore_free(ds);
                ds = NULL;
        }