From: Antonio Ospite Date: Tue, 9 Jun 2015 21:21:08 +0000 (+0200) Subject: Do not use alloca() in app_init(): the memory is used after the return X-Git-Url: https://git.ao2.it/gst-aseq-appsrc.git/commitdiff_plain/9f7e5fde8b002efb97504ee9a4eb464fce4072ed Do not use alloca() in app_init(): the memory is used after the return Also reorder the cleanup sequence in app_finalize(). --- diff --git a/gst-aseq-appsrc.c b/gst-aseq-appsrc.c index b4f6c39..7d4a885 100644 --- a/gst-aseq-appsrc.c +++ b/gst-aseq-appsrc.c @@ -347,7 +347,7 @@ app_init (App * app, char *ports) } app->npfds = snd_seq_poll_descriptors_count (app->seq, POLLIN); - app->pfds = alloca (sizeof (*app->pfds) * app->npfds); + app->pfds = malloc (sizeof (*app->pfds) * app->npfds); if (app->pfds == NULL) { ret = -ENOMEM; goto err_free_buffer; @@ -371,9 +371,10 @@ static void app_finalize (App * app) { /* free the resources */ + free (app->pfds); free (app->buffer); - free (app->ports); snd_midi_event_free (app->parser); + free (app->ports); snd_seq_close (app->seq); }