DrKLO/Telegram · error

Required arguments:

Error message

Required arguments:

What it means

jpegyuv checks argc != 3 at jpegyuv.c:63, expecting exactly two positional arguments (input JPEG path and output YUV path) plus the program name. If the argument count is wrong, it prints a usage banner starting with 'Required arguments:' and returns 1. This is the header line of that usage message.

Source

Thrown at TMessagesProj/jni/mozjpeg/jpegyuv.c:64

  FILE *jpg_fd;
  int luma_width;
  int luma_height;
  int chroma_width;
  int chroma_height;
  int frame_width;
  int yuv_size;
  JSAMPLE *jpg_buffer;
  JSAMPROW yrow_pointer[16];
  JSAMPROW cbrow_pointer[8];
  JSAMPROW crrow_pointer[8];
  JSAMPROW *plane_pointer[3];
  unsigned char *yuv_buffer;
  int x;
  int y;
  FILE *yuv_fd;

  if (argc != 3) {
    fprintf(stderr, "Required arguments:\n");
    fprintf(stderr, "1. Path to JPG input file\n");
    fprintf(stderr, "2. Path to YUV output file\n");
    return 1;
  }

  /* Will check these for validity when opening via 'fopen'. */
  jpg_path = argv[1];
  yuv_path = argv[2];

  cinfo.err = jpeg_std_error(&jerr);
  jpeg_create_decompress(&cinfo);

  jpg_fd = fopen(jpg_path, "rb");
  if (!jpg_fd) {
    fprintf(stderr, "Invalid path to JPEG file!\n");
    return 1;
  }

View on GitHub (pinned to 45ab8f4308)

Solutions

  1. Always pass exactly two arguments: the JPEG input path and the YUV output path
  2. In a JNI wrapper, validate argc before calling jpegyuv's main
  3. In a shell script, use quotes and check $1 and $2 are non-empty

Example fix

// before (JNI)
jpegyuv_main(1, {"jpegyuv"});

// after
char *argv[] = {"jpegyuv", jpg_path, yuv_path};
if (jpg_path == NULL || yuv_path == NULL) return -1;
jpegyuv_main(3, argv);
Defensive patterns

Strategy: validation

Validate before calling

// Validate argument count before calling jpegyuv main
int safe_jpegyuv_main(int argc, char **argv) {
    if (argc != 3) {
        fprintf(stderr, "Usage: %s <input.jpg> <output.yuv>\n", argv[0]);
        return 1;
    }
    if (argv[1] == NULL || argv[1][0] == '\0' ||
        argv[2] == NULL || argv[2][0] == '\0') {
        fprintf(stderr, "Arguments must not be empty\n");
        return 1;
    }
    return jpegyuv_main(argc, argv);
}

Prevention

When it happens

Trigger: Invoking jpegyuv with zero, one, or three+ positional arguments. Forgetting one of the two required arguments. Passing flags that jpegyuv does not recognize (it has no option parser, so flags count as positional args).

Common situations: Wrapper script or JNI caller passes only the input path and forgets the output path. Extra whitespace in argument splitting produces empty args. A caller passes a `-v` or `--help` flag that jpegyuv doesn't support.

Related errors


AI-assisted analysis of DrKLO/Telegram@45ab8f4308 (2026-08-14). Data as JSON: /api/errors/ed87a8fb5233db1a. Report an issue: GitHub.