1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-29 08:01:23 +03:00

Fix a potential memory leak following OOM in the decimal extension.

FossilOrigin-Name: 5127f7376776e6220eb8f83a30aa6b823c23ae0ac76e7ae41b33ca4e03ce236a
This commit is contained in:
drh
2021-05-03 13:24:30 +00:00
parent 736d11ed21
commit e103a8de2d
3 changed files with 12 additions and 11 deletions

View File

@ -459,10 +459,11 @@ static void decimalSubFunc(
Decimal *pA = decimal_new(context, argv[0], 0, 0);
Decimal *pB = decimal_new(context, argv[1], 0, 0);
UNUSED_PARAMETER(argc);
if( pB==0 ) return;
pB->sign = !pB->sign;
decimal_add(pA, pB);
decimal_result(context, pA);
if( pB ){
pB->sign = !pB->sign;
decimal_add(pA, pB);
decimal_result(context, pA);
}
decimal_free(pA);
decimal_free(pB);
}