Fix possible GDateTime leaks in old logger loader.

Thu, 13 Jul 2017 21:38:05 -0400

author
Elliott Sales de Andrade <qulogic@pidgin.im>
date
Thu, 13 Jul 2017 21:38:05 -0400
changeset 38622
0d8e51f600c9
parent 38621
1412d6b993e9
child 38623
2c8018bb892b

Fix possible GDateTime leaks in old logger loader.

libpurple/log.c file | annotate | diff | comparison | revisions
--- a/libpurple/log.c	Wed Jul 12 00:46:26 2017 -0400
+++ b/libpurple/log.c	Thu Jul 13 21:38:05 2017 -0400
@@ -104,7 +104,8 @@
 	if (log->logger && log->logger->finalize)
 		log->logger->finalize(log);
 	g_free(log->name);
-	g_date_time_unref(log->time);
+	if (log->time)
+		g_date_time_unref(log->time);
 
 	PURPLE_DBUS_UNREGISTER_POINTER(log);
 	g_slice_free(PurpleLog, log);
@@ -1686,9 +1687,8 @@
 					newlen--;
 
 				if (newlen != 0) {
-					log = purple_log_new(PURPLE_LOG_IM, sn, account, NULL, NULL);
+					log = purple_log_new(PURPLE_LOG_IM, sn, account, NULL, lasttime);
 					log->logger = old_logger;
-					log->time = g_date_time_ref(lasttime);
 
 					/* IMPORTANT: Always set all members of struct old_logger_data */
 					data = g_slice_new(struct old_logger_data);
@@ -1741,6 +1741,8 @@
 			} else if (purple_strequal(month_str, "Dec")) {
 				month = 12;
 			}
+			if (lasttime)
+				g_date_time_unref(lasttime);
 			lasttime = g_date_time_new_local(year, month, day,
 			                                 hour, minute, second);
 		}
@@ -1748,9 +1750,8 @@
 
 	if (logfound) {
 		if ((newlen = ftell(file) - lastoff) != 0) {
-			log = purple_log_new(PURPLE_LOG_IM, sn, account, NULL, NULL);
+			log = purple_log_new(PURPLE_LOG_IM, sn, account, NULL, lasttime);
 			log->logger = old_logger;
-			log->time = g_date_time_ref(lasttime);
 
 			/* IMPORTANT: Always set all members of struct old_logger_data */
 			data = g_slice_new(struct old_logger_data);
@@ -1767,6 +1768,8 @@
 		}
 	}
 
+	if (lasttime)
+		g_date_time_unref(lasttime);
 	purple_stringref_unref(pathref);
 	fclose(file);
 	if (index != NULL)

mercurial