Skip to content

Commit 1a5541a

Browse files
committed
move the cleanup of money_required to after its final use
1 parent 5941e46 commit 1a5541a

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

matchengine/me_market.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -962,7 +962,6 @@ int market_put_market_order(bool real, json_t **result, market_t *m, uint32_t us
962962
mpd_add(money_required, money_required, deal, &mpd_ctx);
963963
}
964964
skiplist_release_iterator(iter);
965-
mpd_del(money_required);
966965
mpd_del(left);
967966
mpd_del(amount_tx);
968967
mpd_del(price);
@@ -971,8 +970,10 @@ int market_put_market_order(bool real, json_t **result, market_t *m, uint32_t us
971970
// validate user has the balance available to fulfil order
972971
mpd_t *balance = balance_get(user_id, BALANCE_TYPE_AVAILABLE, m->money);
973972
if (!balance || mpd_cmp(balance, money_required, &mpd_ctx) < 0) {
973+
mpd_del(money_required);
974974
return -1;
975975
}
976+
mpd_del(money_required);
976977

977978
// validate there are any market participants on the other side of the order
978979
if (ask_count == 0) {

0 commit comments

Comments
 (0)