diff options
author | Dan Glastonbury <[email protected]> | 2017-05-29 13:12:39 +1000 |
---|---|---|
committer | Matthew Gregan <[email protected]> | 2017-05-29 15:51:19 +1200 |
commit | 040cf4afa26bd46f4343d3b7fd1d2b9211e503b2 (patch) | |
tree | 46a58c2f2ccb6b0c88600e3c0c43124116a42d24 /src/cubeb.c | |
parent | 62871b265996a4b472abcc0be83b11a53631d2e2 (diff) | |
download | cubeb-040cf4afa26bd46f4343d3b7fd1d2b9211e503b2.tar.gz cubeb-040cf4afa26bd46f4343d3b7fd1d2b9211e503b2.zip |
cubeb: Change cubeb_device_collection_destroy to handle invalid data.
Invalid collection if count or device is 0.
Upstream from Gecko Bug 1367646.
Diffstat (limited to 'src/cubeb.c')
-rw-r--r-- | src/cubeb.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/cubeb.c b/src/cubeb.c index 714f88f..7cbe216 100644 --- a/src/cubeb.c +++ b/src/cubeb.c @@ -574,13 +574,24 @@ int cubeb_enumerate_devices(cubeb * context, int cubeb_device_collection_destroy(cubeb * context, cubeb_device_collection * collection) { + int r; + if (context == NULL || collection == NULL) return CUBEB_ERROR_INVALID_PARAMETER; if (!context->ops->device_collection_destroy) return CUBEB_ERROR_NOT_SUPPORTED; - return context->ops->device_collection_destroy(context, collection); + if (!collection->device) + return CUBEB_OK; + + r = context->ops->device_collection_destroy(context, collection); + if (r == CUBEB_OK) { + collection->device = NULL; + collection->count = 0; + } + + return r; } int cubeb_register_device_collection_changed(cubeb * context, |