changeset 26:b9e90a914e20

[gaim-migrate @ 35] Peter Teichman sent me another huge list of patches. Here they are :) committer: Tailor Script <tailor@pidgin.im>
author Rob Flynn <gaim@robflynn.com>
date Fri, 24 Mar 2000 19:17:34 +0000
parents c56db1b46b0d
children 0a2a1b62a66d
files ChangeLog src/aim.c src/browser.c src/buddy.c src/buddy_chat.c src/dialogs.c src/gaim.h src/gaimrc.c src/gtkhtml.c src/network.c src/util.c
diffstat 11 files changed, 77 insertions(+), 48 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Fri Mar 24 08:55:32 2000 +0000
+++ b/ChangeLog	Fri Mar 24 19:17:34 2000 +0000
@@ -13,7 +13,7 @@
 	* Various GNOME Applet Enhancements (thanks AGAIN to 
 	  Eric.  Someone needs to stop this boy :-) ) 
 	* A lot of random, obscure bugs fixed
-	* About 6 memory leaks fixed (yes, we're embarassed)
+	* About very many memory leaks fixed (yes, we're embarassed)
 	  (Thanks to Jeramey and Peter Teichman for these!)
 	
 version 0.9.11:
--- a/src/aim.c	Fri Mar 24 08:55:32 2000 +0000
+++ b/src/aim.c	Fri Mar 24 19:17:34 2000 +0000
@@ -62,7 +62,7 @@
 GtkWidget *mainwindow = NULL;
 
 char toc_addy[16];
-char *quad_addr;
+char *quad_addr = NULL;
 
 
 void cancel_logon(void)
--- a/src/browser.c	Fri Mar 24 08:55:32 2000 +0000
+++ b/src/browser.c	Fri Mar 24 19:17:34 2000 +0000
@@ -135,10 +135,17 @@
     XGetWindowProperty(dpy, win, WM_STATE, 0, 0, False, AnyPropertyType,
                        &type, &format, &nitems, &after, &data);
     if (type)
-        return win;
+    {
+	XFree(data);
+	return win;
+    }
+
     inf = TryChildren(dpy, win, WM_STATE);
     if (!inf)
         inf = win;
+
+    XFree(data);
+
     return inf;
 }
 
@@ -166,6 +173,8 @@
                            &after, &data);
         if (type)
             inf = children[i];
+
+	XFree(data);
     }
     for (i = 0; !inf && (i < nchildren); i++)
         inf = TryChildren(dpy, children[i], WM_STATE);
@@ -212,7 +221,7 @@
         if (!(kids && nkids)) {
                 sprintf (debug_buff, "%s: root window has no children on display %s\n",
                          progname, DisplayString (gdk_display));
-				debug_print(debug_buff);
+		debug_print(debug_buff);
             	return NULL;
         }
 
@@ -228,8 +237,10 @@
                                                  False, XA_STRING,
                                                  &type, &format, &nitems, &bytesafter,
                                                  &version);
+
                 if (! version)
                         continue;
+
                 if (strcmp ((char *) version, expected_mozilla_version) &&
                     !tenative)
                 {
@@ -237,7 +248,7 @@
                         tenative_version = version;
                         continue;
                 }
-                g_free (version);
+                XFree(version);
                 if (status == Success && type != None)
                 {
                         result = w;
@@ -245,6 +256,8 @@
                 }
         }
 
+	XFree(kids);
+
         if (result && tenative)
         {
             sprintf (debug_buff,
@@ -254,7 +267,7 @@
                          expected_mozilla_version, (unsigned int) result,
                          expected_mozilla_version);
 			debug_print(debug_buff);
-            g_free (tenative_version);
+            XFree(tenative_version);
             return gdk_window_foreign_new(result);
         }
         else if (tenative)
@@ -265,7 +278,7 @@
                      progname, expected_mozilla_version,
                      tenative_version, (unsigned int) tenative);
 			debug_print(debug_buff);
-            g_free (tenative_version);
+            XFree(tenative_version);
             return gdk_window_foreign_new(tenative);
         }
         else if (result)
@@ -594,6 +607,7 @@
 
 		netscape_lock = 0;
 		
+		gdk_window_destroy (window);
 	} else {
 		pid = fork();
 		if (pid == 0) {
--- a/src/buddy.c	Fri Mar 24 08:55:32 2000 +0000
+++ b/src/buddy.c	Fri Mar 24 19:17:34 2000 +0000
@@ -1131,18 +1131,19 @@
 
 void do_pounce(char *name)
 {
-        char *who = g_malloc(64);
-        char *buf = g_malloc(BUF_LONG);
+        char *who;
         
         struct buddy_pounce *b;
 	struct conversation *c;
 
 	GList *bp = buddy_pounces;
         
-        strcpy(who, normalize(name));
+	who = g_strdup(normalize(name));
 
 	while(bp) {
 		b = (struct buddy_pounce *)bp->data;;
+		bp = bp->next; /* increment the list here because rem_bp can make our handle bad */
+
                 if (!strcasecmp(who, normalize(b->name))) {
 			if (b->popup == 1)
 			{
@@ -1166,10 +1167,8 @@
                         rem_bp(NULL, b);
                         
                 }
-                bp = bp->next;
         }
         g_free(who);
-        g_free(buf);
 }
 
 static void new_bp_callback(GtkWidget *w, char *name)
@@ -1300,7 +1299,6 @@
 
 void set_buddy(struct buddy *b)
 {
-	char *who;
 	char infotip[256];
         char idlet[16];
         char warn[256];
@@ -1359,10 +1357,6 @@
 			
 			play_sound(BUDDY_ARRIVE);
 
-			who = g_malloc(sizeof(b->name) + 10);
-			strcpy(who, b->name);
-	
-			g_free(who);
 			pm = gdk_pixmap_create_from_xpm_d(blist->window, &bm,
 				NULL, (gchar **)login_icon_xpm);
 			gtk_widget_hide(b->pix);
--- a/src/buddy_chat.c	Fri Mar 24 08:55:32 2000 +0000
+++ b/src/buddy_chat.c	Fri Mar 24 19:17:34 2000 +0000
@@ -465,6 +465,8 @@
 	win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
 	b->window = win;
 
+	gtk_window_set_policy(GTK_WINDOW(win), TRUE, TRUE, TRUE);
+
 	close = gtk_button_new_with_label("Close");
 	invite_btn = gtk_button_new_with_label("Invite");
 	whisper = gtk_button_new_with_label("Whisper");
--- a/src/dialogs.c	Fri Mar 24 08:55:32 2000 +0000
+++ b/src/dialogs.c	Fri Mar 24 19:17:34 2000 +0000
@@ -776,8 +776,9 @@
 {
         struct buddy_pounce *bp = g_new0(struct buddy_pounce, 1);
 	
-        strcpy(bp->name, gtk_entry_get_text(GTK_ENTRY(b->nameentry)));
-        strcpy(bp->message, gtk_entry_get_text(GTK_ENTRY(b->messentry)));
+	g_snprintf(bp->name, 80, "%s", gtk_entry_get_text(GTK_ENTRY(b->nameentry)));
+	g_snprintf(bp->message, 2048, "%s", gtk_entry_get_text(GTK_ENTRY(b->messentry)));
+
 	if (GTK_TOGGLE_BUTTON(b->openwindow)->active)
 		bp->popup = 1;
 	else
@@ -787,11 +788,11 @@
 		bp->sendim = 1;
 	else
 		bp->sendim = 0;
+
         buddy_pounces = g_list_append(buddy_pounces, bp);
 	
         do_bp_menu();
         
-        
         destroy_dialog(NULL, b->window);
         g_free(b);
 }
--- a/src/gaim.h	Fri Mar 24 08:55:32 2000 +0000
+++ b/src/gaim.h	Fri Mar 24 19:17:34 2000 +0000
@@ -269,7 +269,7 @@
 #define TYPE_SIGNOFF   4
 #define TYPE_KEEPALIVE 5
 
-#define REVISION "gaim:$Revision: 19 $"
+#define REVISION "gaim:$Revision: 35 $"
 #define FLAPON "FLAPON\r\n\r\n"
 
 #define ROAST "Tic/Toc"
@@ -399,6 +399,7 @@
 /* Functions in util.c */
 extern char *normalize(const char *);
 extern int escape_text(char *);
+extern char *escape_text2(char *);
 extern int escape_message(char *msg);
 extern char *frombase64(char *);
 extern gint clean_pid(void *);
--- a/src/gaimrc.c	Fri Mar 24 08:55:32 2000 +0000
+++ b/src/gaimrc.c	Fri Mar 24 19:17:34 2000 +0000
@@ -203,8 +203,19 @@
 	fprintf(f, "away {\n");
 
 	while (awy) {
+		char *str1, *str2;
+
 		a = (struct away_message *)awy->data;
-		fprintf(f, "\tmessage { %s } { %s }\n", escape_text2(a->name), escape_text2(a->message));
+
+		str1 = escape_text2(a->name);
+		str2 = escape_text2(a->message);
+
+		fprintf(f, "\tmessage { %s } { %s }\n", str1, str2);
+
+		/* escape_text2 uses malloc(), so we don't want to g_free these */
+		free(str1);
+		free(str2);
+
 		awy = awy->next;
 	}
 
--- a/src/gtkhtml.c	Fri Mar 24 08:55:32 2000 +0000
+++ b/src/gtkhtml.c	Fri Mar 24 19:17:34 2000 +0000
@@ -1510,6 +1510,8 @@
 			if ((realx > hb->x && realx < (hb->x + hb->width)) &&
 				(realy < hb->y && realy > (hb->y - hb->height)))
 			{
+				GdkCursor *cursor = NULL;
+
 				if (html->tooltip_hb != hb)
 				{
 					html->tooltip_hb = hb;
@@ -1524,8 +1526,11 @@
 						gtk_timeout_add(HTML_TOOLTIP_DELAY,
 										gtk_html_tooltip_timeout, html);
 				}
-				gdk_window_set_cursor(html->html_area,
-									  gdk_cursor_new(GDK_HAND2));
+
+				cursor = gdk_cursor_new(GDK_HAND2);
+				gdk_window_set_cursor(html->html_area, cursor);
+				gdk_cursor_destroy(cursor);
+
 				return TRUE;
 			}
 			urls = urls->next;
@@ -2856,17 +2861,19 @@
 			num--;
 		else
 		{
-
-			html->current_x = 0;
-			if (nl)
-			{
-				text[length] = '\n';
-				length++;
+			if (html->current_x != 0) {
+				html->current_x = 0;
+				if (nl) {
+					text[length] = '\n';
+					length++;
+				}
+				gtk_html_add_text(html, cfont, fore, back, text, length, uline, strike, url);
+				g_free(text);
+				return;
+			} else {
+				num = strlen (text);
+				break;
 			}
-			gtk_html_add_text(html, cfont, fore, back, text, length, uline,
-							  strike, url);
-			g_free(text);
-			return;
 		}
 
 	}
@@ -2922,17 +2929,9 @@
 		 * This is kinda cheesy but it may make things
 		 * * much better lookin 
 		 */
-		for (i = 2; i < 15; i++)
-		{
-			if ((num - i) < 0)
-			{
-				html->current_x = 0;
-				gtk_html_add_text(html, cfont, fore, back, text, strlen(text),
-								  uline, strike, url);
-				return;
-			}
-			else if (text[num - i] == ' ')
-			{
+
+		for (i=2; (num - i > 0); i++) {
+			if (text[num - i] == ' ') {
 				num = num - (i - 1);
 				nl2 = 1;
 				break;
--- a/src/network.c	Fri Mar 24 08:55:32 2000 +0000
+++ b/src/network.c	Fri Mar 24 19:17:34 2000 +0000
@@ -57,7 +57,10 @@
 	fd = socket(AF_INET, SOCK_STREAM, 0);
 	
 	if (fd > -1) {
-		quad_addr=strdup(inet_ntoa(sin.sin_addr));
+		if (quad_addr)
+			g_free (quad_addr);
+		
+		quad_addr=g_strdup(inet_ntoa(sin.sin_addr));
 		if (proxy_connect(fd, (struct sockaddr *)&sin, sizeof(sin)) > -1) {
 			return fd;
 		}
--- a/src/util.c	Fri Mar 24 08:55:32 2000 +0000
+++ b/src/util.c	Fri Mar 24 19:17:34 2000 +0000
@@ -492,6 +492,8 @@
                 c++;
         }
         woo[cnt]='\0';
+
+	g_free (cpy);
         return woo;
 }
 
@@ -617,12 +619,14 @@
         char *t, *u;
         int x=0;
 
-        u = t = g_malloc(strlen(s) + 1);
+        g_return_if_fail (s != NULL);
+
+        u = t = g_strdup(s);
 
         strcpy(t, s);
         g_strdown(t);
         
-	while(*t) {
+	while(*t && (x < BUF_LEN - 1)) {
 		if (*t != ' ') {
 			buf[x] = *t;
 			x++;