mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
spa: alsa: avoid potential uninitialized variable use
In both funtions `ctl_hndl` could be passed to `snd_ctl_close()` while being unitialized if `this->device_info.change_mask` is zero.
This commit is contained in:
parent
27b76ae686
commit
ab2907c699
2 changed files with 22 additions and 16 deletions
|
|
@ -242,8 +242,6 @@ static int emit_info(struct impl *this, bool full)
|
|||
int err = 0;
|
||||
struct spa_dict_item items[20];
|
||||
uint32_t n_items = 0;
|
||||
snd_ctl_t *ctl_hndl;
|
||||
snd_ctl_card_info_t *info;
|
||||
char path[128];
|
||||
char device_name[200];
|
||||
char device_desc[200];
|
||||
|
|
@ -252,6 +250,9 @@ static int emit_info(struct impl *this, bool full)
|
|||
this->device_info.change_mask = this->info_all;
|
||||
|
||||
if (this->device_info.change_mask) {
|
||||
snd_ctl_card_info_t *info;
|
||||
snd_ctl_t *ctl_hndl;
|
||||
|
||||
spa_log_debug(this->log, "open card %s", this->props.device);
|
||||
if ((err = snd_ctl_open(&ctl_hndl, this->props.device, 0)) < 0) {
|
||||
spa_log_error(this->log, "can't open control for card %s: %s",
|
||||
|
|
@ -260,9 +261,14 @@ static int emit_info(struct impl *this, bool full)
|
|||
}
|
||||
|
||||
snd_ctl_card_info_alloca(&info);
|
||||
if ((err = snd_ctl_card_info(ctl_hndl, info)) < 0) {
|
||||
err = snd_ctl_card_info(ctl_hndl, info);
|
||||
|
||||
spa_log_debug(this->log, "close card %s", this->props.device);
|
||||
snd_ctl_close(ctl_hndl);
|
||||
|
||||
if (err < 0) {
|
||||
spa_log_error(this->log, "error hardware info: %s", snd_strerror(err));
|
||||
goto finish;
|
||||
return err;
|
||||
}
|
||||
|
||||
snprintf(path, sizeof(path), "alsa:compressed:%s", snd_ctl_card_info_get_id(info));
|
||||
|
|
@ -297,10 +303,7 @@ static int emit_info(struct impl *this, bool full)
|
|||
this->device_info.change_mask = 0;
|
||||
}
|
||||
|
||||
finish:
|
||||
spa_log_debug(this->log, "close card %s", this->props.device);
|
||||
snd_ctl_close(ctl_hndl);
|
||||
return err;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int impl_add_listener(void *object,
|
||||
|
|
|
|||
|
|
@ -247,14 +247,15 @@ static int emit_info(struct impl *this, bool full)
|
|||
int err = 0;
|
||||
struct spa_dict_item items[20];
|
||||
uint32_t n_items = 0;
|
||||
snd_ctl_t *ctl_hndl;
|
||||
snd_ctl_card_info_t *info;
|
||||
char path[128];
|
||||
|
||||
if (full)
|
||||
this->device_info.change_mask = this->info_all;
|
||||
|
||||
if (this->device_info.change_mask) {
|
||||
snd_ctl_card_info_t *info;
|
||||
snd_ctl_t *ctl_hndl;
|
||||
|
||||
spa_log_debug(this->log, "open card %s", this->props.device);
|
||||
if ((err = snd_ctl_open(&ctl_hndl, this->props.device, 0)) < 0) {
|
||||
spa_log_error(this->log, "can't open control for card %s: %s",
|
||||
|
|
@ -263,9 +264,14 @@ static int emit_info(struct impl *this, bool full)
|
|||
}
|
||||
|
||||
snd_ctl_card_info_alloca(&info);
|
||||
if ((err = snd_ctl_card_info(ctl_hndl, info)) < 0) {
|
||||
err = snd_ctl_card_info(ctl_hndl, info);
|
||||
|
||||
spa_log_debug(this->log, "close card %s", this->props.device);
|
||||
snd_ctl_close(ctl_hndl);
|
||||
|
||||
if (err < 0) {
|
||||
spa_log_error(this->log, "error hardware info: %s", snd_strerror(err));
|
||||
goto exit;
|
||||
return err;
|
||||
}
|
||||
|
||||
#define ADD_ITEM(key, value) items[n_items++] = SPA_DICT_ITEM_INIT(key, value)
|
||||
|
|
@ -296,10 +302,7 @@ static int emit_info(struct impl *this, bool full)
|
|||
this->device_info.change_mask = 0;
|
||||
}
|
||||
|
||||
exit:
|
||||
spa_log_debug(this->log, "close card %s", this->props.device);
|
||||
snd_ctl_close(ctl_hndl);
|
||||
return err;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int impl_add_listener(void *object,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue