From 7f57f1d450e83dbea8c29fdc1ffcda59a371ba20 Mon Sep 17 00:00:00 2001 From: Harry van Haaren Date: Sun, 9 Apr 2017 15:33:57 +0100 Subject: [PATCH] fix possible mem leak if loading a MIDI binding fails --- src/controller/genericmidi.cxx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/controller/genericmidi.cxx b/src/controller/genericmidi.cxx index 9033643..7976ff8 100644 --- a/src/controller/genericmidi.cxx +++ b/src/controller/genericmidi.cxx @@ -784,10 +784,10 @@ Binding* GenericMIDI::setupBinding( cJSON* binding ) // create binding, then fill in data as from JSON. Binding* tmp = new Binding(); - cJSON* actionJson = cJSON_GetObjectItem( binding, "action" ); if ( !actionJson ) { LUPPP_WARN("Binding doesn't have action field: fix .ctlr file"); + delete tmp; return 0; } @@ -795,6 +795,7 @@ Binding* GenericMIDI::setupBinding( cJSON* binding ) cJSON* dataJson = cJSON_GetObjectItem( binding, "data" ); if ( !statusJson || !dataJson ) { LUPPP_WARN("Binding w Action:%s doesn't have status / data field: fix .ctlr file", actionJson->valuestring); + delete tmp; return 0; } @@ -889,8 +890,8 @@ Binding* GenericMIDI::setupBinding( cJSON* binding ) LUPPP_WARN("Binding action not recognized: %s", actionJson->valuestring ); } + delete tmp; return 0; - }