Skip to content

Commit 3f789c2

Browse files
committed
move the cleanup of money_required to after its final use
1 parent b7b5e5e commit 3f789c2

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
@@ -956,7 +956,6 @@ int market_put_market_order(bool real, json_t **result, market_t *m, uint32_t us
956956
mpd_add(money_required, money_required, deal, &mpd_ctx);
957957
}
958958
skiplist_release_iterator(iter);
959-
mpd_del(money_required);
960959
mpd_del(left);
961960
mpd_del(amount_tx);
962961
mpd_del(price);
@@ -965,8 +964,10 @@ int market_put_market_order(bool real, json_t **result, market_t *m, uint32_t us
965964
// validate user has the balance available to fulfil order
966965
mpd_t *balance = balance_get(user_id, BALANCE_TYPE_AVAILABLE, m->money);
967966
if (!balance || mpd_cmp(balance, money_required, &mpd_ctx) < 0) {
967+
mpd_del(money_required);
968968
return -1;
969969
}
970+
mpd_del(money_required);
970971

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

0 commit comments

Comments
 (0)