summaryrefslogtreecommitdiffstats
path: root/plugins/alsa/alsa-api-pcm.c
diff options
context:
space:
mode:
authorThierry Bultel <thierry.bultel@iot.bzh>2018-06-11 16:21:00 +0200
committerThierry Bultel <thierry.bultel@iot.bzh>2018-06-11 16:21:00 +0200
commitb53304b2ff507801aeb19aa38291f328458e57e9 (patch)
tree212ab0dee1b171a26b36cd10873360f6983c09bd /plugins/alsa/alsa-api-pcm.c
parentaf967e17050d813aaf209a4c6197775d3b92bcfb (diff)
Fixed compilation warning with _FORTIFY_SOURCE=2
Signed-off-by: Thierry Bultel <thierry.bultel@iot.bzh>
Diffstat (limited to 'plugins/alsa/alsa-api-pcm.c')
-rw-r--r--plugins/alsa/alsa-api-pcm.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/plugins/alsa/alsa-api-pcm.c b/plugins/alsa/alsa-api-pcm.c
index 084b54b..d67433e 100644
--- a/plugins/alsa/alsa-api-pcm.c
+++ b/plugins/alsa/alsa-api-pcm.c
@@ -417,6 +417,7 @@ OnErrorExit:
PUBLIC AlsaSndPcmT * ApiPcmAttachOne(SoftMixerT *mixer, const char *uid, snd_pcm_stream_t direction, json_object * argsJ) {
AlsaSndPcmT *pcm = calloc(1, sizeof (AlsaSndPcmT));
json_object *sourceJ = NULL, *paramsJ = NULL, *sinkJ = NULL, *targetJ = NULL;
+ char *apiVerb = NULL, *apiInfo = NULL;
int error;
pcm->sndcard = (AlsaSndCtlT*) calloc(1, sizeof (AlsaSndCtlT));
@@ -518,13 +519,16 @@ PUBLIC AlsaSndPcmT * ApiPcmAttachOne(SoftMixerT *mixer, const char *uid, snd_pcm
if (error) goto OnErrorExit;
// create master control for this sink
- char *apiVerb, *apiInfo;
if (direction == SND_PCM_STREAM_PLAYBACK) {
- (void) asprintf(&apiVerb, "%s:playback", pcm->uid);
- (void) asprintf(&apiInfo, "HAL:%s SND_PCM_STREAM_PLAYBACK", uid);
+ if (asprintf(&apiVerb, "%s:playback", pcm->uid) == -1)
+ goto OnErrorExit;
+ if (asprintf(&apiInfo, "HAL:%s SND_PCM_STREAM_PLAYBACK", uid) == -1)
+ goto OnErrorExit;
} else {
- (void) asprintf(&apiVerb, "%s:capture", pcm->uid);
- (void) asprintf(&apiInfo, "HAL:%s SND_PCM_STREAM_PLAYBACK", uid);
+ if (asprintf(&apiVerb, "%s:capture", pcm->uid) == -1)
+ goto OnErrorExit;
+ if (asprintf(&apiInfo, "HAL:%s SND_PCM_STREAM_PLAYBACK", uid) == -1)
+ goto OnErrorExit;
}
apiVerbHandleT *handle = calloc(1, sizeof (apiVerbHandleT));
@@ -546,6 +550,8 @@ PUBLIC AlsaSndPcmT * ApiPcmAttachOne(SoftMixerT *mixer, const char *uid, snd_pcm
OnErrorExit:
free(pcm);
+ free(apiVerb);
+ free(apiInfo);
return NULL;
}