audioc.c: Always free IO buffer.
[paraslash.git] / audioc.c
index e12d6e98fce4baa902d03e21c48aee4fba0237da..5f92888979387b3dbe443b085e98ae0d9632ebe8 100644 (file)
--- a/audioc.c
+++ b/audioc.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005-2011 Andre Noll <maan@systemlinux.org>
+ * Copyright (C) 2005-2012 Andre Noll <maan@systemlinux.org>
  *
  * Licensed under the GPL v2. For licencing details see COPYING.
  */
@@ -298,7 +298,9 @@ int main(int argc, char *argv[])
                        .check_required = 0,
                        .check_ambiguity = 0
                };
-               if (audioc_cmdline_parser_config_file(cf, &conf, &params)) {
+               ret = audioc_cmdline_parser_config_file(cf, &conf, &params);
+               free(cf);
+               if (ret) {
                        fprintf(stderr, "parse error in config file\n");
                        exit(EXIT_FAILURE);
                }
@@ -332,6 +334,9 @@ int main(int argc, char *argv[])
                goto out;
        bufsize = conf.bufsize_arg;
        buf = para_malloc(bufsize);
+       ret = mark_fd_blocking(STDOUT_FILENO);
+       if (ret < 0)
+               goto out;
        do {
                size_t n = ret = recv_bin_buffer(fd, buf, bufsize);
                if (ret <= 0)
@@ -339,6 +344,7 @@ int main(int argc, char *argv[])
                ret = write_all(STDOUT_FILENO, buf, &n);
        } while (ret >= 0);
 out:
+       free(buf);
        if (ret < 0)
                PARA_ERROR_LOG("%s\n", para_strerror(-ret));
        return ret < 0? EXIT_FAILURE : EXIT_SUCCESS;