]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
channelstorage_cpp_map_name_id: Fix callback returning non-matching channels. master
authorGeorge Joseph <gjoseph@sangoma.com>
Wed, 9 Jul 2025 17:14:55 +0000 (11:14 -0600)
committergithub-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Thu, 10 Jul 2025 15:07:21 +0000 (15:07 +0000)
When the callback() API was invoked but no channel passed the test, callback
would return the last channel tested instead of NULL.  It now correctly
returns NULL when no channel matches.

Resolves: #1288

main/channelstorage_cpp_map_name_id.cc

index 1b3d1770677e3f85ec6b6aa7faeaf10a281250d5..4e73b2d5d26567b2204de24c50079044acbe034e 100644 (file)
@@ -151,12 +151,13 @@ static struct ast_channel *callback(struct ast_channelstorage_instance *driver,
                chan = it->second;
                if (cb_fn(chan, arg, data, ao2_flags) == (CMP_MATCH | CMP_STOP)) {
                        ao2_bump(chan);
-                       break;
+                       unlock(driver);
+                       return chan;
                }
        }
        unlock(driver);
 
-       return chan;
+       return NULL;
 }
 
 enum cpp_map_iterator_type {