Skip to content

Commit

Permalink
Fix invalid argument handling
Browse files Browse the repository at this point in the history
Fixes #61
  • Loading branch information
arkq committed Sep 10, 2017
1 parent 79f68a9 commit dae9e75
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/asound/bluealsa-pcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -620,24 +620,22 @@ SND_PCM_PLUGIN_DEFINE_FUNC(bluealsa) {
return -EINVAL;
}

if ((pcm = calloc(1, sizeof(*pcm))) == NULL)
return -ENOMEM;

bdaddr_t addr;
enum pcm_type type;

if (device == NULL || str2ba(device, &addr) != 0) {
SNDERR("Invalid BT device address: %s", device);
ret = -errno;
goto fail;
return -EINVAL;
}

if ((type = bluealsa_parse_profile(profile)) == PCM_TYPE_NULL) {
SNDERR("Invalid BT profile [a2dp, sco]: %s", profile);
ret = -errno;
goto fail;
return -EINVAL;
}

if ((pcm = calloc(1, sizeof(*pcm))) == NULL)
return -ENOMEM;

pcm->fd = -1;
pcm->event_fd = -1;
pcm->pcm_fd = -1;
Expand Down

0 comments on commit dae9e75

Please sign in to comment.