Fix memory leak in case of exceptions thrown when parsing the variable from json