swtpm_utils: Use SWTPM_G_FREE macro to free memory and set pointer to NULL

Use the macro in swtpm_setup.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
diff --git a/src/swtpm_setup/swtpm_setup.c b/src/swtpm_setup/swtpm_setup.c
index aafa448..a42256c 100644
--- a/src/swtpm_setup/swtpm_setup.c
+++ b/src/swtpm_setup/swtpm_setup.c
@@ -278,10 +278,8 @@
                 }
                 g_strfreev(lines);
 
-                g_free(standard_output);
-                standard_output = NULL;
-                g_free(standard_error);
-                standard_error = NULL;
+                SWTPM_G_FREE(standard_output);
+                SWTPM_G_FREE(standard_error);
             }
         }
     }
@@ -379,8 +377,7 @@
                 g_free(certfile);
                 certfile = g_strjoin(G_DIR_SEPARATOR_S, certsdir, flags_to_certfiles[idx].filename, NULL);
 
-                g_free(filecontent);
-                filecontent = NULL;
+                SWTPM_G_FREE(filecontent);
                 ret = read_file(certfile, &filecontent, &filecontent_len);
                 if (ret != 0)
                     return 1;
@@ -620,8 +617,7 @@
             certfile = g_strjoin(G_DIR_SEPARATOR_S, certsdir,
                                  flags_to_certfiles[idx].filename, NULL);
 
-            g_free(filecontent);
-            filecontent = NULL;
+            SWTPM_G_FREE(filecontent);
             ret = read_file(certfile, &filecontent, &filecontent_len);
             if (ret != 0)
                 return 1;
diff --git a/src/utils/swtpm_utils.h b/src/utils/swtpm_utils.h
index 897993c..7dbee1a 100644
--- a/src/utils/swtpm_utils.h
+++ b/src/utils/swtpm_utils.h
@@ -23,6 +23,12 @@
         (FD) = -1;	\
     }
 
+#define SWTPM_G_FREE(var)	\
+    do {		\
+        g_free(var);	\
+        var = NULL;	\
+    } while(0)
+
 extern gchar *gl_LOGFILE;
 
 void append_to_file(const char *pathname, const char *str);