Browse Source

don't free any config strings - who cares for a few bytes?

this fixes some crashes at exit.
0.9
Oswald Buddenhagen 22 years ago
parent
commit
28e240a36b
  1. 19
      src/config.c
  2. 1
      src/isync.h
  3. 22
      src/main.c

19
src/config.c

@ -172,7 +172,6 @@ load_config (const char *where, int *o2o)
if (boxes) if (boxes)
goto forbid; goto forbid;
/* this only affects the global setting */ /* this only affects the global setting */
free (global.maildir);
global.maildir = expand_strdup (val); global.maildir = expand_strdup (val);
} }
else if (!strcasecmp ("folder", cmd)) else if (!strcasecmp ("folder", cmd))
@ -204,14 +203,7 @@ load_config (const char *where, int *o2o)
cfg->host = strdup (val); cfg->host = strdup (val);
} }
else if (!strcasecmp ("user", cmd)) else if (!strcasecmp ("user", cmd))
{ cfg->user = strdup (val);
if (boxes)
cfg->user = strdup (val);
else {
free (global.user);
global.user = strdup (val);
}
}
else if (!strcasecmp ("pass", cmd)) else if (!strcasecmp ("pass", cmd))
cfg->pass = strdup (val); cfg->pass = strdup (val);
else if (!strcasecmp ("port", cmd)) else if (!strcasecmp ("port", cmd))
@ -288,12 +280,3 @@ find_box (const char *s)
} }
return 0; return 0;
} }
void
free_config (void)
{
free (global.user);
free (global.maildir);
free (global.host);
free (global.pass);
}

1
src/isync.h

@ -196,7 +196,6 @@ int sync_mailbox (mailbox_t *, imap_t *, int, unsigned int, unsigned int);
void load_config (const char *, int *); void load_config (const char *, int *);
char * expand_strdup (const char *s); char * expand_strdup (const char *s);
config_t *find_box (const char *); config_t *find_box (const char *);
void free_config (void);
void imap_close (imap_t *); void imap_close (imap_t *);
int imap_copy_message (imap_t * imap, unsigned int uid, const char *mailbox); int imap_copy_message (imap_t * imap, unsigned int uid, const char *mailbox);

22
src/main.c

@ -35,10 +35,6 @@
#include <dirent.h> #include <dirent.h>
#include "isync.h" #include "isync.h"
#if HAVE_GETOPT_LONG
#define _GNU_SOURCE
#include <getopt.h>
int Quiet; int Quiet;
void void
@ -61,6 +57,9 @@ infoc (char c)
putchar (c); putchar (c);
} }
#if HAVE_GETOPT_LONG
# define _GNU_SOURCE
# include <getopt.h>
struct option Opts[] = { struct option Opts[] = {
{"all", 0, NULL, 'a'}, {"all", 0, NULL, 'a'},
{"list", 0, NULL, 'l'}, {"list", 0, NULL, 'l'},
@ -183,7 +182,7 @@ int
main (int argc, char **argv) main (int argc, char **argv)
{ {
int i; int i;
int ret = 1; int ret;
config_t *box = 0; config_t *box = 0;
mailbox_t *mail = 0; mailbox_t *mail = 0;
imap_t *imap = 0; imap_t *imap = 0;
@ -274,8 +273,7 @@ main (int argc, char **argv)
global.folder = optarg; global.folder = optarg;
break; break;
case 'M': case 'M':
free (global.maildir); global.maildir = optarg;
global.maildir = strdup (optarg);
break; break;
case 'I': case 'I':
global.inbox = optarg; global.inbox = optarg;
@ -291,7 +289,6 @@ main (int argc, char **argv)
global.host = optarg; global.host = optarg;
break; break;
case 'u': case 'u':
free (global.user);
global.user = optarg; global.user = optarg;
break; break;
case 'V': case 'V':
@ -348,9 +345,9 @@ main (int argc, char **argv)
imap = imap_connect (&global); imap = imap_connect (&global);
if (!imap) if (!imap)
goto bork; return 1;
if (imap_list (imap)) if (imap_list (imap))
goto bork; return 1;
} }
if (list) if (list)
{ {
@ -462,12 +459,7 @@ main (int argc, char **argv)
if (all) if (all)
box = box->next; box = box->next;
} }
/* gracefully close connection to the IMAP server */ /* gracefully close connection to the IMAP server */
imap_close (imap); imap_close (imap);
bork:
free_config ();
return ret; return ret;
} }

Loading…
Cancel
Save