Commit 46cba868 for libheif
commit 46cba868814164c8f5c335c508f9c587e2d11231
Author: Dirk Farin <dirk.farin@gmail.com>
Date: Tue Sep 29 23:21:00 2026 +0200
heif-enc: exit with an error when an option is unknown
getopt_long() reports an unknown option, or an option without its argument,
with the return value '?'. heif-enc did not handle it and went on, so a
mistyped option was ignored and the image was encoded with the default value.
diff --git a/examples/heif_enc.cc b/examples/heif_enc.cc
index c8a51ca0..5f3bfec9 100644
--- a/examples/heif_enc.cc
+++ b/examples/heif_enc.cc
@@ -1906,6 +1906,11 @@ int main(int argc, char** argv)
case OPTION_RAW_ENDIAN:
raw_input_params.big_endian = (std::string(optarg) == "big");
break;
+ case '?':
+ // An unknown option, or an option without its argument. getopt_long() has
+ // printed which one it is.
+ std::cerr << "Use '" << argv[0] << " --help' for the list of options.\n";
+ return 5;
}
}