diff --git a/tests/tiny_psnr.c b/tests/tiny_psnr.c
index 5db266247823c72f9d2866031eae99710269cc23..a53a67038bcefa0d584eefdaca9e5101804d8ed8 100644
--- a/tests/tiny_psnr.c
+++ b/tests/tiny_psnr.c
@@ -139,7 +139,7 @@ int main(int argc, char *argv[])
         } else {
             char *end;
             len = strtol(argv[3], &end, 0);
-            if (*end || len > 2) {
+            if (*end || len < 1 || len > 2) {
                 fprintf(stderr, "Unsupported sample format: %s\n", argv[3]);
                 return 1;
             }