mirror of
https://github.com/reactos/reactos.git
synced 2024-08-06 11:24:58 +00:00
Checking memory allocation return values helps prevent crashes
svn path=/trunk/; revision=20316
This commit is contained in:
parent
9851ee0b33
commit
7ca33cb6d6
|
@ -304,9 +304,12 @@ union mcluster {
|
|||
#ifdef __REACTOS__
|
||||
#define MCLGET(m, how) { \
|
||||
OS_DbgPrint(OSK_MID_TRACE,("(MCLGET) m = %x\n", m)); \
|
||||
(m)->m_data = (m)->m_ext.ext_buf = malloc(MCLBYTES); \
|
||||
(m)->m_flags |= M_EXT; \
|
||||
(m)->m_ext.ext_size = MCLBYTES; \
|
||||
(m)->m_ext.ext_buf = malloc(MCLBYTES); \
|
||||
if ((m)->m_ext.ext_buf != NULL) { \
|
||||
(m)->m_data = (m)->m_ext.ext_buf; \
|
||||
(m)->m_flags |= M_EXT; \
|
||||
(m)->m_ext.ext_size = MCLBYTES; \
|
||||
} \
|
||||
}
|
||||
|
||||
#define MCLFREE(p) { \
|
||||
|
|
|
@ -366,8 +366,17 @@ sendit:
|
|||
#ifdef __REACTOS__
|
||||
if( OtcpEvent.PacketSend ) {
|
||||
struct mbuf *new_m;
|
||||
MGET( new_m, M_DONTWAIT, 0 );
|
||||
new_m = m_get( M_DONTWAIT, 0 );
|
||||
if ( NULL == new_m ) {
|
||||
error = ENOBUFS;
|
||||
goto done;
|
||||
}
|
||||
MCLGET( new_m, M_DONTWAIT );
|
||||
if (0 == (new_m->m_flags & M_EXT)) {
|
||||
m_free( new_m );
|
||||
error = ENOBUFS;
|
||||
goto done;
|
||||
}
|
||||
m_copydata( m, 0, htons(ip->ip_len), new_m->m_data );
|
||||
new_m->m_len = htons(ip->ip_len);
|
||||
error = OtcpEvent.PacketSend( OtcpEvent.ClientData,
|
||||
|
@ -498,7 +507,16 @@ sendorfree:
|
|||
if( error == 0 && OtcpEvent.PacketSend ) {
|
||||
struct mbuf *new_m;
|
||||
MGET( new_m, M_DONTWAIT, 0 );
|
||||
if ( NULL == new_m ) {
|
||||
error = ENOBUFS;
|
||||
goto done;
|
||||
}
|
||||
MCLGET( new_m, M_DONTWAIT );
|
||||
if (0 == (new_m->m_flags & M_EXT)) {
|
||||
m_free( new_m );
|
||||
error = ENOBUFS;
|
||||
goto done;
|
||||
}
|
||||
m_copydata( m, 0, htons(ip->ip_len), new_m->m_data );
|
||||
new_m->m_len = htons(ip->ip_len);
|
||||
error = OtcpEvent.PacketSend( OtcpEvent.ClientData,
|
||||
|
|
Loading…
Reference in a new issue