fixed acessing members of freed pfile struct
authorThorsten Maerz <torte@netztorte.de>
Thu, 2 Jan 2003 04:21:25 +0000 (04:21 +0000)
committerThorsten Maerz <torte@netztorte.de>
Thu, 2 Jan 2003 04:21:25 +0000 (04:21 +0000)
ChangeLog.claws
configure.in
src/common/prefs.c

index 88378f7c1f619eae1bdfd64d35bf8b9013efcd3f..fc5f966feb499ea0f6c3437727836b28eb14a011 100644 (file)
@@ -1,3 +1,8 @@
+2003-01-02 [thorsten]  0.8.8claws38
+
+       * src/prefs.c
+               fixed acessing members of freed pfile struct
+
 2003-01-02 [thorsten]  0.8.8claws37
 
        * src/procmsg.c
 2003-01-02 [thorsten]  0.8.8claws37
 
        * src/procmsg.c
index a14a4a09dbe54c531be6b251ab78e9c2ae40f2f9..1a405eca2c3f5e99dbe1d5ddf31350591f2103c2 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=8
 MICRO_VERSION=8
 INTERFACE_AGE=0
 BINARY_AGE=0
 MICRO_VERSION=8
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws37
+EXTRA_VERSION=claws38
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl set $target
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl set $target
index 29483a2199f5b09d2039a38c8260f9fe89f8e885..844a38b6e59654c05a3c01cbedf5756427b31ade 100644 (file)
 #include "prefs.h"
 #include "utils.h"
 
 #include "prefs.h"
 #include "utils.h"
 
+/*!
+ *\brief       Open preferences file for reading
+ *
+ *\param       path Filename with path of preferences file to read
+ *
+ *\return      PrefFile * preferences file struct
+ */
 PrefFile *prefs_read_open(const gchar *path)
 {
        PrefFile *pfile;
 PrefFile *prefs_read_open(const gchar *path)
 {
        PrefFile *pfile;
@@ -50,6 +57,15 @@ PrefFile *prefs_read_open(const gchar *path)
        return pfile;
 }
 
        return pfile;
 }
 
+/*!
+ *\brief       Open preferences file for writing
+ *             Prefs are written to a temp file: Call prefs_write_close()
+ *             to rename this to the final filename
+ *
+ *\param       path Filename with path of preferences file to write
+ *
+ *\return      PrefFile * preferences file struct
+ */
 PrefFile *prefs_write_open(const gchar *path)
 {
        PrefFile *pfile;
 PrefFile *prefs_write_open(const gchar *path)
 {
        PrefFile *pfile;
@@ -84,6 +100,21 @@ PrefFile *prefs_write_open(const gchar *path)
        return pfile;
 }
 
        return pfile;
 }
 
+/*!
+ *\brief       Close and free preferences file
+ *             Creates final file from temp, creates backup
+ *
+ *\param       pfile Preferences file struct
+ *
+ *\return      0 on success, -1 on failure
+ */
+#define PREFS_FILE_FREE() \
+{ \
+  if (path)    g_free(path); \
+  if (tmppath) g_free(tmppath); \
+  if (bakpath) g_free(bakpath); \
+  if (pfile)   g_free(pfile); \
+}
 gint prefs_file_close(PrefFile *pfile)
 {
        FILE *fp, *orig_fp;
 gint prefs_file_close(PrefFile *pfile)
 {
        FILE *fp, *orig_fp;
@@ -97,10 +128,11 @@ gint prefs_file_close(PrefFile *pfile)
        fp = pfile->fp;
        orig_fp = pfile->orig_fp;
        path = pfile->path;
        fp = pfile->fp;
        orig_fp = pfile->orig_fp;
        path = pfile->path;
-       g_free(pfile);
 
        if (!pfile->writing) {
                fclose(fp);
 
        if (!pfile->writing) {
                fclose(fp);
+               g_free(pfile);
+               g_free(path);
                return 0;
        }
 
                return 0;
        }
 
@@ -159,12 +191,19 @@ gint prefs_file_close(PrefFile *pfile)
                return -1;
        }
 
                return -1;
        }
 
+       g_free(pfile);
        g_free(path);
        g_free(tmppath);
        g_free(bakpath);
        return 0;
 }
        g_free(path);
        g_free(tmppath);
        g_free(bakpath);
        return 0;
 }
+#undef PREFS_FILE_FREE
 
 
+/*!
+ *\brief       Close and free preferences file, delete temp file
+ *
+ *\param       pfile Preferences file struct
+ */
 gint prefs_file_close_revert(PrefFile *pfile)
 {
        gchar *tmppath;
 gint prefs_file_close_revert(PrefFile *pfile)
 {
        gchar *tmppath;
@@ -186,6 +225,9 @@ gint prefs_file_close_revert(PrefFile *pfile)
        return 0;
 }
 
        return 0;
 }
 
+/*!
+ *\brief       Check if "path" is a file and readonly
+ */
 gboolean prefs_is_readonly(const gchar * path)
 {
        if (path == NULL)
 gboolean prefs_is_readonly(const gchar * path)
 {
        if (path == NULL)
@@ -194,6 +236,9 @@ gboolean prefs_is_readonly(const gchar * path)
        return (access(path, W_OK) != 0 && access(path, F_OK) == 0);
 }
 
        return (access(path, W_OK) != 0 && access(path, F_OK) == 0);
 }
 
+/*!
+ *\brief       Check if "rcfile" is in rcdir, a file and readonly
+ */
 gboolean prefs_rc_is_readonly(const gchar * rcfile)
 {
        gboolean result;
 gboolean prefs_rc_is_readonly(const gchar * rcfile)
 {
        gboolean result;
@@ -209,6 +254,14 @@ gboolean prefs_rc_is_readonly(const gchar * rcfile)
        return result;
 }
 
        return result;
 }
 
+/*!
+ *\brief       Selects current section in preferences file
+ *             Creates section if file is written
+ *
+ *\param       pfile Preferences file struct
+ *
+ *\return      0 on success, -1 on failure
+ */
 gint prefs_set_block_label(PrefFile *pfile, const gchar *label)
 {
        gchar *block_label;
 gint prefs_set_block_label(PrefFile *pfile, const gchar *label)
 {
        gchar *block_label;