Backport better zephyr coverity fix from default release-2.x.y

Thu, 15 May 2014 17:29:04 +0200

author
Tomasz Wasilczyk <twasilczyk@pidgin.im>
date
Thu, 15 May 2014 17:29:04 +0200
branch
release-2.x.y
changeset 36040
8f2d69e2b8b5
parent 36038
c986b1e3fa1d
child 36041
7f35f441b939

Backport better zephyr coverity fix from default

libpurple/protocols/zephyr/Zinternal.c file | annotate | diff | comparison | revisions
--- a/libpurple/protocols/zephyr/Zinternal.c	Thu May 15 15:19:58 2014 +0200
+++ b/libpurple/protocols/zephyr/Zinternal.c	Thu May 15 17:29:04 2014 +0200
@@ -526,15 +526,17 @@
 		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 @@
 		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;

mercurial