Don't use msg on error.
[openssl.git] / crypto / bio / bss_dgram.c
index 8a55c1521b633186402df6b51386e9c5bf72f31b..8a1eb6de8b2357a372b954830692aa026ff5f7d8 100644 (file)
@@ -1082,6 +1082,13 @@ static int dgram_sctp_read(BIO *b, char *out, int outl)
                        msg.msg_flags = 0;
                        n = recvmsg(b->num, &msg, 0);
 
                        msg.msg_flags = 0;
                        n = recvmsg(b->num, &msg, 0);
 
+                       if (n <= 0)
+                               {
+                               if (n < 0)
+                                       ret = n;
+                               break;
+                               }
+
                        if (msg.msg_controllen > 0)
                                {
                                for (cmsg = CMSG_FIRSTHDR(&msg); cmsg; cmsg = CMSG_NXTHDR(&msg, cmsg))
                        if (msg.msg_controllen > 0)
                                {
                                for (cmsg = CMSG_FIRSTHDR(&msg); cmsg; cmsg = CMSG_NXTHDR(&msg, cmsg))
@@ -1121,13 +1128,6 @@ static int dgram_sctp_read(BIO *b, char *out, int outl)
                                        }
                                }
 
                                        }
                                }
 
-                       if (n <= 0)
-                               {
-                               if (n < 0)
-                                       ret = n;
-                               break;
-                               }
-
                        if (msg.msg_flags & MSG_NOTIFICATION)
                                {
                                snp = (union sctp_notification*) out;
                        if (msg.msg_flags & MSG_NOTIFICATION)
                                {
                                snp = (union sctp_notification*) out;