comparison mcabber/src/histolog.c @ 1560:ec55cdf44335

Fix a memory leak in hlog_get_log_jid()
author Mikael Berthe <mikael@lilotux.net>
date Fri, 17 Oct 2008 18:55:58 +0200
parents 071c8170b7de
children a087125d8fc8
comparison
equal deleted inserted replaced
1559:0674abda9a8f 1560:ec55cdf44335
68 struct stat bufstat; 68 struct stat bufstat;
69 char *path; 69 char *path;
70 char *log_jid = NULL; 70 char *log_jid = NULL;
71 71
72 path = user_histo_file(bjid); 72 path = user_histo_file(bjid);
73 do { 73 while (path) {
74 if (lstat(path, &bufstat) != 0) 74 if (lstat(path, &bufstat) != 0)
75 break; 75 break;
76 if (S_ISLNK(bufstat.st_mode)) { 76 if (S_ISLNK(bufstat.st_mode)) {
77 g_free(log_jid); 77 g_free(log_jid);
78 log_jid = g_new(char, bufstat.st_size+1); 78 log_jid = g_new0(char, bufstat.st_size+1);
79 readlink(path, log_jid, bufstat.st_size); 79 readlink(path, log_jid, bufstat.st_size);
80 g_free(path); 80 g_free(path);
81 log_jid[bufstat.st_size] = '\0';
82 path = user_histo_file(log_jid); 81 path = user_histo_file(log_jid);
83 } else { 82 } else
84 g_free(path); 83 break;
85 path = NULL; 84 }
86 } 85
87 } while( path ); 86 g_free(path);
88
89 return log_jid; 87 return log_jid;
90 } 88 }
91 89
92 // write_histo_line() 90 // write_histo_line()
93 // Adds a history (multi-)line to the jid's history logfile 91 // Adds a history (multi-)line to the jid's history logfile