Skip to content

Commit af29817

Browse files
committed
coreaudio: add alloc assertions
1 parent 5a32d7c commit af29817

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

src/audio/capture/coreaudio.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
#include <AudioUnit/AudioUnit.h>
4545
#include <Availability.h>
4646
#include <CoreAudio/AudioHardware.h>
47+
#include <assert.h>
4748
#include <pthread.h>
4849
#include <stdlib.h>
4950
#include <string.h>
@@ -271,6 +272,7 @@ static void (^cb)(BOOL) = ^void(BOOL granted) {
271272
}
272273

273274
struct state_ca_capture *s = (struct state_ca_capture *) calloc(1, sizeof(struct state_ca_capture));
275+
assert(s != NULL);
274276
pthread_mutex_init(&s->lock, NULL);
275277
pthread_cond_init(&s->cv, NULL);
276278
s->boss_waiting = FALSE;

src/audio/playback/coreaudio.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ void audio_ca_probe(struct device_info **available_devices, int *count, int dir)
305305
assert(dir == -1 || dir == 1);
306306
*available_devices =
307307
(struct device_info *) calloc(1, sizeof(struct device_info));
308+
assert(*available_devices != nullptr);
308309
snprintf((*available_devices)[0].dev, sizeof(*available_devices)[0].dev,
309310
"");
310311
snprintf((*available_devices)[0].name,
@@ -342,6 +343,7 @@ void audio_ca_probe(struct device_info **available_devices, int *count, int dir)
342343

343344
(*count)++;
344345
*available_devices = (struct device_info *) realloc(*available_devices, *count * sizeof(struct device_info));
346+
assert(*available_devices != nullptr);
345347
memset(&(*available_devices)[*count - 1], 0, sizeof(struct device_info));
346348

347349
audio_ca_get_device_name(dev_ids[i], sizeof (*available_devices)[*count - 1].name,

0 commit comments

Comments
 (0)