mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-22 17:05:36 +01:00
Merge remote-tracking branch 'rasp/mem-leak' into development
* rasp/mem-leak:
Fix another potential memory leak found by find-mem-leak.cocci.
Add a rule for another type of memory leak to find-mem-leak.cocci.
Fix a potential memory leak found by find-mem-leak.cocci.
Add a semantic patch to find potential memory leaks.
Fix whitespace of 369e6c20
.
Apply the semantic patch rm-malloc-cast.cocci.
Add a semantic patch to remove casts of malloc.
Conflicts:
programs/ssl/ssl_server2.c
This commit is contained in:
commit
ac08b543db
@ -4064,8 +4064,13 @@ int ssl_set_psk( ssl_context *ssl, const unsigned char *psk, size_t psk_len,
|
||||
ssl->psk = polarssl_malloc( ssl->psk_len );
|
||||
ssl->psk_identity = polarssl_malloc( ssl->psk_identity_len );
|
||||
|
||||
if( ssl->psk == NULL || ssl->psk_identity == NULL )
|
||||
if( ssl->psk == NULL )
|
||||
return( POLARSSL_ERR_SSL_MALLOC_FAILED );
|
||||
if( ssl->psk_identity == NULL )
|
||||
{
|
||||
polarssl_free( ssl->psk );
|
||||
return( POLARSSL_ERR_SSL_MALLOC_FAILED );
|
||||
}
|
||||
|
||||
memcpy( ssl->psk, psk, ssl->psk_len );
|
||||
memcpy( ssl->psk_identity, psk_identity, ssl->psk_identity_len );
|
||||
|
20
scripts/find-mem-leak.cocci
Normal file
20
scripts/find-mem-leak.cocci
Normal file
@ -0,0 +1,20 @@
|
||||
@@
|
||||
expression x, y;
|
||||
statement S;
|
||||
@@
|
||||
x = polarssl_malloc(...);
|
||||
y = polarssl_malloc(...);
|
||||
...
|
||||
* if (x == NULL || y == NULL)
|
||||
S
|
||||
|
||||
@@
|
||||
expression x, y;
|
||||
statement S;
|
||||
@@
|
||||
if (
|
||||
* (x = polarssl_malloc(...)) == NULL
|
||||
||
|
||||
* (y = polarssl_malloc(...)) == NULL
|
||||
)
|
||||
S
|
Loading…
Reference in New Issue
Block a user