Dont crash on socket_fork when out of memory.

git-svn-id: svn://kolibrios.org@5155 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
hidnplayr 2014-11-01 18:27:28 +00:00
parent 274d2c309b
commit 22d5b72b64
2 changed files with 20 additions and 2 deletions

View File

@ -1223,10 +1223,13 @@ SOCKET_pair:
lea eax, [eax + STREAM_SOCKET.rcv] lea eax, [eax + STREAM_SOCKET.rcv]
call SOCKET_ring_create call SOCKET_ring_create
test eax, eax
jz .nomem1
lea eax, [ebx + STREAM_SOCKET.rcv] lea eax, [ebx + STREAM_SOCKET.rcv]
call SOCKET_ring_create call SOCKET_ring_create
pop eax test eax, eax
jz .nomem2
ret ret
@ -1468,7 +1471,8 @@ SOCKET_input:
;-------------------------- ;--------------------------
; ;
; eax = ptr to ring struct (just a buffer of the right size) ; IN: eax = ptr to ring struct (just a buffer of the right size)
; OUT: eax = unchanged / 0 on error
; ;
align 4 align 4
SOCKET_ring_create: SOCKET_ring_create:
@ -1479,6 +1483,8 @@ SOCKET_ring_create:
push edx push edx
stdcall create_ring_buffer, SOCKET_MAXDATA, PG_SW stdcall create_ring_buffer, SOCKET_MAXDATA, PG_SW
pop edx pop edx
test eax, eax
jz .fail
DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_ring_created: %x\n", eax DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_ring_created: %x\n", eax
@ -1496,6 +1502,7 @@ SOCKET_ring_create:
mov eax, esi mov eax, esi
pop esi pop esi
.fail:
ret ret
;----------------------------------------------------------------- ;-----------------------------------------------------------------
@ -1539,6 +1546,7 @@ SOCKET_ring_write:
jb @f jb @f
sub edi, SOCKET_MAXDATA ; WRAP sub edi, SOCKET_MAXDATA ; WRAP
@@: @@:
mov [eax + RING_BUFFER.write_ptr], edi mov [eax + RING_BUFFER.write_ptr], edi
pop edi pop edi
@ -1954,8 +1962,14 @@ SOCKET_free:
jnz .no_tcp jnz .no_tcp
mov ebx, eax mov ebx, eax
cmp [ebx + STREAM_SOCKET.rcv.start_ptr], 0
je @f
stdcall kernel_free, [ebx + STREAM_SOCKET.rcv.start_ptr] stdcall kernel_free, [ebx + STREAM_SOCKET.rcv.start_ptr]
@@:
cmp [ebx + STREAM_SOCKET.snd.start_ptr], 0
je @f
stdcall kernel_free, [ebx + STREAM_SOCKET.snd.start_ptr] stdcall kernel_free, [ebx + STREAM_SOCKET.snd.start_ptr]
@@:
mov eax, ebx mov eax, ebx
.no_tcp: .no_tcp:

View File

@ -1235,9 +1235,13 @@ align 4
lea eax, [ebx + STREAM_SOCKET.snd] lea eax, [ebx + STREAM_SOCKET.snd]
call SOCKET_ring_create call SOCKET_ring_create
test eax, eax
jz .drop
lea eax, [ebx + STREAM_SOCKET.rcv] lea eax, [ebx + STREAM_SOCKET.rcv]
call SOCKET_ring_create call SOCKET_ring_create
test eax, eax
jz .drop
and [temp_bits], not TCP_BIT_DROPSOCKET and [temp_bits], not TCP_BIT_DROPSOCKET