From 88a1a79bc13175ae04db2d58195d3b67a34b2981 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tim=20R=C3=BChsen?= <tim.ruehsen@gmx.de>
Date: Sun, 30 Aug 2015 13:13:05 +0200
Subject: [PATCH] Fix leaks found by Coverity

* src/http.c (parse_strict_transport_security): Free c_max_age
             (open_output_stream): Fix indentation
* src/iri.c (locale_to_utf8): Free new
---
 src/http.c | 13 +++++++++----
 src/iri.c  |  1 +
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/src/http.c b/src/http.c
index 406d3296..99f63385 100644
--- a/src/http.c
+++ b/src/http.c
@@ -1274,7 +1274,10 @@ parse_strict_transport_security (const char *header, time_t *max_age, bool *incl
       for (; extract_param (&header, &name, &value, ';', &is_url_encoded); is_url_encoded = false)
         {
           if (BOUNDED_EQUAL_NO_CASE (name.b, name.e, "max-age"))
-            c_max_age = strdupdelim (value.b, value.e);
+            {
+              xfree(c_max_age);
+              c_max_age = strdupdelim (value.b, value.e);
+            }
           else if (BOUNDED_EQUAL_NO_CASE (name.b, name.e, "includeSubDomains"))
             is = true;
         }
@@ -2486,9 +2489,10 @@ open_output_stream (struct http_stat *hs, int count, FILE **fp)
     *fp = output_stream;
 
   /* Print fetch message, if opt.verbose.  */
-      logprintf (LOG_VERBOSE, _("Saving to: %s\n"),
-                 HYPHENP (hs->local_file) ? quote ("STDOUT") : quote (hs->local_file));
-      return RETROK;
+  logprintf (LOG_VERBOSE, _("Saving to: %s\n"),
+             HYPHENP (hs->local_file) ? quote ("STDOUT") : quote (hs->local_file));
+
+  return RETROK;
 }
 
 /* Set proper type flags based on type string.  */
@@ -2625,6 +2629,7 @@ metalink_from_http (const struct response *resp, const struct http_stat *hs,
                   logprintf (LOG_NOTQUIET, _("When downloading signature:\n"
                                              "%s: %s.\n"), urlstr, error);
                   xfree (error);
+                  iri_free (iri);
                 }
               else
                 {
diff --git a/src/iri.c b/src/iri.c
index c9505ce8..dc9aa9ad 100644
--- a/src/iri.c
+++ b/src/iri.c
@@ -231,6 +231,7 @@ locale_to_utf8 (const char *str)
   if (do_conversion ("UTF-8", opt.locale, (char *) str, strlen ((char *) str), &new))
     return (const char *) new;
 
+  xfree (new);
   return str;
 }