inidb: Avoid calling fclose() twice 85/30985/2
authorTanu Kaskinen <tanu.kaskinen@linux.intel.com>
Fri, 28 Nov 2014 08:55:30 +0000 (10:55 +0200)
committerJaska Uimonen <jaska.uimonen@intel.com>
Thu, 11 Dec 2014 18:57:33 +0000 (10:57 -0800)
f needs to be set to NULL after calling fclose(), otherwise fclose
will be called again in the "fail" section if the first call fails,
which results in undefined behaviour (a crash has been observed[1]).

[1] https://lists.tizen.org/pipermail/ivi/2014-November/003693.html

Change-Id: Iaa1539a379b8be31b62834f49240d17fdf45c893

src/modules/volume-api/inidb.c

index 8116e72..62a2825 100644 (file)
@@ -326,6 +326,7 @@ static void save(pa_inidb *db) {
     }
 
     r = fclose(f);
+    f = NULL;
     if (r < 0) {
         pa_log("fclose() failed: %s", pa_cstrerror(errno));
         goto fail;