/pidgin/main: 8f2d69e2b8b5: Backport better zephyr coverity fix ...

Tomasz Wasilczyk twasilczyk at pidgin.im
Thu May 15 11:29:21 EDT 2014


Changeset: 8f2d69e2b8b5f37f59eae3320d3b1efec0d9e39a
Author:	 Tomasz Wasilczyk <twasilczyk at pidgin.im>
Date:	 2014-05-15 17:29 +0200
Branch:	 release-2.x.y
URL: https://hg.pidgin.im/pidgin/main/rev/8f2d69e2b8b5

Description:

Backport better zephyr coverity fix from default

diffstat:

 libpurple/protocols/zephyr/Zinternal.c |  20 ++++++++++++--------
 1 files changed, 12 insertions(+), 8 deletions(-)

diffs (47 lines):

diff --git a/libpurple/protocols/zephyr/Zinternal.c b/libpurple/protocols/zephyr/Zinternal.c
--- a/libpurple/protocols/zephyr/Zinternal.c
+++ b/libpurple/protocols/zephyr/Zinternal.c
@@ -526,15 +526,17 @@ Code_t Z_AddNoticeToEntry(qptr, notice, 
 		hole = hole->next;
 	    }
 	    if (lasthole) {
-		if (!(lasthole->next = (struct _Z_Hole *)(struct _Z_InputQ *)
-		      malloc(sizeof(struct _Z_InputQ))))
+		struct _Z_InputQ *inputq = malloc(sizeof(struct _Z_InputQ));
+		if (!inputq)
 		    return (ENOMEM);
+		lasthole->next = (struct _Z_Hole *)inputq;
 		hole = lasthole->next;
 	    }
 	    else {
-		if (!(qptr->holelist = (struct _Z_Hole *)(struct _Z_InputQ *)
-		      malloc(sizeof(struct _Z_InputQ))))
+		struct _Z_InputQ *inputq = malloc(sizeof(struct _Z_InputQ));
+		if (!inputq)
 		    return (ENOMEM);
+		qptr->holelist = (struct _Z_Hole *)inputq;
 		hole = qptr->holelist;
 	    }
 	    hole->next = NULL;
@@ -550,15 +552,17 @@ Code_t Z_AddNoticeToEntry(qptr, notice, 
 		hole = hole->next;
 	    }
 	    if (lasthole) {
-		if (!(lasthole->next = (struct _Z_Hole *)(struct _Z_InputQ *)
-		      malloc(sizeof(struct _Z_InputQ))))
+		struct _Z_InputQ *inputq = malloc(sizeof(struct _Z_InputQ));
+		if (!inputq)
 		    return (ENOMEM);
+		lasthole->next = (struct _Z_Hole *)inputq;
 		hole = lasthole->next;
 	    }
 	    else {
-		if (!(qptr->holelist = (struct _Z_Hole *)(struct _Z_InputQ *)
-		      malloc(sizeof(struct _Z_InputQ))))
+		struct _Z_InputQ *inputq = malloc(sizeof(struct _Z_InputQ));
+		if (!inputq)
 		    return (ENOMEM);
+		qptr->holelist = (struct _Z_Hole *)inputq;
 		hole = qptr->holelist;
 	    }
 	    hole->next = (struct _Z_Hole *) 0;



More information about the Commits mailing list