netconn_alloc(): return on invalid protocol instead of initializing mbox size to 0

This commit is contained in:
Simon Goldschmidt 2011-09-03 21:24:06 +02:00 committed by goldsimon
parent adb2aeb10f
commit e6a179ea32

View File

@ -597,18 +597,16 @@ netconn_alloc(enum netconn_type t, netconn_callback callback)
#endif /* LWIP_TCP */ #endif /* LWIP_TCP */
default: default:
LWIP_ASSERT("netconn_alloc: undefined netconn_type", 0); LWIP_ASSERT("netconn_alloc: undefined netconn_type", 0);
break; goto free_and_return;
} }
#endif #endif
if (sys_sem_new(&conn->op_completed, 0) != ERR_OK) { if (sys_sem_new(&conn->op_completed, 0) != ERR_OK) {
memp_free(MEMP_NETCONN, conn); goto free_and_return;
return NULL;
} }
if (sys_mbox_new(&conn->recvmbox, size) != ERR_OK) { if (sys_mbox_new(&conn->recvmbox, size) != ERR_OK) {
sys_sem_free(&conn->op_completed); sys_sem_free(&conn->op_completed);
memp_free(MEMP_NETCONN, conn); goto free_and_return;
return NULL;
} }
#if LWIP_TCP #if LWIP_TCP
@ -633,6 +631,9 @@ netconn_alloc(enum netconn_type t, netconn_callback callback)
#endif /* LWIP_SO_RCVBUF */ #endif /* LWIP_SO_RCVBUF */
conn->flags = 0; conn->flags = 0;
return conn; return conn;
free_and_return:
memp_free(MEMP_NETCONN, conn);
return NULL;
} }
/** /**