{"record":{"id":"2290ce6164184296","repo":"DrKLO/Telegram","slug":"invalid-image-size-input-n","errorCode":null,"errorMessage":"Invalid image size input!\\n","messagePattern":"Invalid image size input!\\\\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"TMessagesProj/jni/mozjpeg/yuvjpeg.c","lineNumber":135,"sourceCode":"    fprintf(stderr, \"Required arguments:\\n\");\n    fprintf(stderr, \"1. JPEG quality value, 0-100\\n\");\n    fprintf(stderr, \"2. Image size (e.g. '512x512')\\n\");\n    fprintf(stderr, \"3. Path to YUV input file\\n\");\n    fprintf(stderr, \"4. Path to JPG output file\\n\");\n    return 1;\n  }\n\n  errno = 0;\n\n  quality = strtol(argv[1], NULL, 10);\n  if (errno != 0 || quality < 0 || quality > 100) {\n    fprintf(stderr, \"Invalid JPEG quality value!\\n\");\n    return 1;\n  }\n\n  matches = sscanf(argv[2], \"%dx%d\", &luma_width, &luma_height);\n  if (matches != 2) {\n    fprintf(stderr, \"Invalid image size input!\\n\");\n    return 1;\n  }\n  if (luma_width <= 0 || luma_height <= 0) {\n    fprintf(stderr, \"Invalid image size input!\\n\");\n    return 1;\n  }\n\n  chroma_width = (luma_width + 1) >> 1;\n  chroma_height = (luma_height + 1) >> 1;\n\n  /* Will check these for validity when opening via 'fopen'. */\n  yuv_path = argv[3];\n  jpg_path = argv[4];\n\n  yuv_fd = fopen(yuv_path, \"r\");\n  if (!yuv_fd) {\n    fprintf(stderr, \"Invalid path to YUV file!\\n\");\n    return 1;","sourceCodeStart":117,"sourceCodeEnd":153,"githubUrl":"https://github.com/DrKLO/Telegram/blob/45ab8f4308496e1f01026a97fcdb0d58a5274474/TMessagesProj/jni/mozjpeg/yuvjpeg.c#L117-L153","documentation":"yuvjpeg parses argv[2] as image size using sscanf(argv[2], \"%dx%d\", &luma_width, &luma_height). If sscanf does not return 2 (the token does not contain an `x`-separated pair of integers), it prints `Invalid image size input!` and returns 1. This catches syntactically malformed size tokens before any dimension logic.","triggerScenarios":"Passing a size token that is not exactly `<int>x<int>`, e.g. `512`, `512X512`, `512 x 512`, `512*512`, or an empty string.","commonSituations":"Using uppercase X, adding spaces around the separator, using a different delimiter, or a UI that formats dimensions with a multiplication sign.","solutions":["Format the size as lowercase `WxH` with no spaces, e.g. 512x512.","Validate argv[2] against ^[0-9]+x[0-9]+$ before invoking.","Normalize the separator to lowercase 'x' in the calling code."],"exampleFix":"// before\nyuvjpeg 90 512X512 in.yuv out.jpg\n// after\nyuvjpeg 90 512x512 in.yuv out.jpg","handlingStrategy":"validation","validationCode":"int w, h;\n/* sscanf must yield exactly 2 ints separated by lowercase x */\nif (sscanf(size_arg, \"%dx%d\", &w, &h) != 2) { /* reject malformed size */ }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use lowercase 'x' with no surrounding spaces.","Reject uppercase X, '*', or ' x ' separators upstream.","Validate with ^[0-9]+x[0-9]+$ before invoking."],"tags":["cli","jpeg","mozjpeg","yuvjpeg","input-validation","format"],"backgroundTag":null,"analyzedSha":"45ab8f4308496e1f01026a97fcdb0d58a5274474","analyzedAt":"2026-08-14T05:19:30.815Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}