pidgin: dcd1194e: oscar: g_malloc can't fail (in a way tha...

darkrain42 at pidgin.im darkrain42 at pidgin.im
Sun May 16 02:00:55 EDT 2010


-----------------------------------------------------------------
Revision: dcd1194eb2bd80a296737c518ce2474661d9fa1f
Ancestor: 2a7ad9dd15f080096423a10b56336b0f1c25783a
Author: darkrain42 at pidgin.im
Date: 2010-05-16T05:57:08
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/dcd1194eb2bd80a296737c518ce2474661d9fa1f

Modified files:
        libpurple/protocols/oscar/snac.c

ChangeLog: 

oscar: g_malloc can't fail (in a way that doesn't abort)

-------------- next part --------------
============================================================
--- libpurple/protocols/oscar/snac.c	8490e6d35cb37dc5d1c05ed6d099596ffe3af759
+++ libpurple/protocols/oscar/snac.c	7e1787d9bda83810314c218edf62b5d507b68858
@@ -56,11 +56,9 @@ aim_snacid_t aim_cachesnac(OscarData *od
 	snac.type = type;
 	snac.flags = flags;
 
-	if (datalen) {
-		if (!(snac.data = g_malloc(datalen)))
-			return 0; /* er... */
-		memcpy(snac.data, data, datalen);
-	} else
+	if (datalen)
+		snac.data = g_memdup(data, datalen);
+	else
 		snac.data = NULL;
 
 	return aim_newsnac(od, &snac);
@@ -78,9 +76,7 @@ aim_snacid_t aim_newsnac(OscarData *od, 
 	if (!newsnac)
 		return 0;
 
-	if (!(snac = g_malloc(sizeof(aim_snac_t))))
-		return 0;
-	memcpy(snac, newsnac, sizeof(aim_snac_t));
+	snac = g_memdup(newsnac, sizeof(aim_snac_t));
 	snac->issuetime = time(NULL);
 
 	index = snac->id % FAIM_SNAC_HASH_SIZE;


More information about the Commits mailing list