mirror of
				https://github.com/godotengine/godot.git
				synced 2025-10-31 21:51:22 +00:00 
			
		
		
		
	[Crypto] Delete mbedtls ctx in deconstructor.
Would cause memory leak when the context was `start`ed but not `finish`ed.
This commit is contained in:
		
							parent
							
								
									a525e77740
								
							
						
					
					
						commit
						a28d25c441
					
				
					 3 changed files with 9 additions and 0 deletions
				
			
		|  | @ -82,6 +82,7 @@ public: | ||||||
| 	virtual PackedByteArray finish() = 0; | 	virtual PackedByteArray finish() = 0; | ||||||
| 
 | 
 | ||||||
| 	HMACContext() {} | 	HMACContext() {} | ||||||
|  | 	virtual ~HMACContext() {} | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| class Crypto : public RefCounted { | class Crypto : public RefCounted { | ||||||
|  |  | ||||||
|  | @ -249,6 +249,13 @@ PackedByteArray HMACContextMbedTLS::finish() { | ||||||
| 	return out; | 	return out; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | HMACContextMbedTLS::~HMACContextMbedTLS() { | ||||||
|  | 	if (ctx != nullptr) { | ||||||
|  | 		mbedtls_md_free((mbedtls_md_context_t *)ctx); | ||||||
|  | 		memfree((mbedtls_md_context_t *)ctx); | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  | 
 | ||||||
| Crypto *CryptoMbedTLS::create() { | Crypto *CryptoMbedTLS::create() { | ||||||
| 	return memnew(CryptoMbedTLS); | 	return memnew(CryptoMbedTLS); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -119,6 +119,7 @@ public: | ||||||
| 	virtual PackedByteArray finish(); | 	virtual PackedByteArray finish(); | ||||||
| 
 | 
 | ||||||
| 	HMACContextMbedTLS() {} | 	HMACContextMbedTLS() {} | ||||||
|  | 	~HMACContextMbedTLS(); | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| class CryptoMbedTLS : public Crypto { | class CryptoMbedTLS : public Crypto { | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Fabio Alessandrelli
						Fabio Alessandrelli