Do not use alloca() in app_init(): the memory is used after the return
[gst-aseq-appsrc.git] / gst-aseq-appsrc.c
index b4f6c39..7d4a885 100644 (file)
@@ -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);
 }