diff --git a/src/cli.cc b/src/cli.cc index 4583427..2ba1040 100644 --- a/src/cli.cc +++ b/src/cli.cc @@ -194,10 +194,12 @@ ot::status ot::read_comments(FILE* input, std::list& comments) } std::string utf8; ot::status rc = to_utf8(line, nread, utf8); - if (rc == ot::st::ok) + if (rc == ot::st::ok) { comments.emplace_back(std::move(utf8)); - else + } else { + free(line); return {ot::st::badly_encoded, "UTF-8 conversion error: " + rc.message}; + } } free(line); return ot::st::ok;