DrKLO/Telegram · error

1. Path to JPG input file

Error message

1. Path to JPG input file

What it means

This is the second line of the usage message printed when argc != 3 (jpegyuv.c:65). It specifies the first required argument: the path to the JPG input file. It is always printed together with error 153 as part of the same usage block. By itself it indicates the caller omitted or miscounted arguments.

Source

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

  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;
  }

  jpeg_stdio_src(&cinfo, jpg_fd);

View on GitHub (pinned to 45ab8f4308)

Solutions

  1. Pass arguments in the correct order: first the JPEG input, then the YUV output
  2. Validate both paths are non-NULL and non-empty before calling jpegyuv
  3. Add an argument-count assertion in the JNI wrapper

Example fix

// before (wrong order)
jpegyuv yuv_output.jpg input.jpg

// after (correct order)
jpegyuv input.jpg yuv_output.yuv
Defensive patterns

Strategy: validation

Validate before calling

// Ensure the first positional argument is a non-empty path string
int validate_args(int argc, char **argv) {
    if (argc != 3) return -1;
    // First arg (after program name) must be a non-empty, readable path
    if (argv[1] == NULL || strlen(argv[1]) == 0) return -1;
    if (argv[2] == NULL || strlen(argv[2]) == 0) return -1;
    return 0;
}

Prevention

When it happens

Trigger: Same as error 153: argc != 3. This line specifically communicates that the first positional argument must be a valid JPEG file path.

Common situations: JNI caller passes only the output path, or passes arguments in the wrong order (YUV output first, JPEG input second). A shell script forgets to pass the input path variable.

Related errors


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