{"record":{"id":"61c952489281099c","repo":"DrKLO/Telegram","slug":"can-t-open-table-file-s","errorCode":null,"errorMessage":"Can't open table file %s\n","messagePattern":"Can't open table file (.+?)\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"TMessagesProj/jni/mozjpeg/rdswitch.c","lineNumber":98,"sourceCode":"GLOBAL(boolean)\nread_quant_tables(j_compress_ptr cinfo, char *filename, boolean force_baseline)\n/* Read a set of quantization tables from the specified file.\n * The file is plain ASCII text: decimal numbers with whitespace between.\n * Comments preceded by '#' may be included in the file.\n * There may be one to NUM_QUANT_TBLS tables in the file, each of 64 values.\n * The tables are implicitly numbered 0,1,etc.\n * NOTE: does not affect the qslots mapping, which will default to selecting\n * table 0 for luminance (or primary) components, 1 for chrominance components.\n * You must use -qslots if you want a different component->table mapping.\n */\n{\n  FILE *fp;\n  int tblno, i, termchar;\n  long val;\n  unsigned int table[DCTSIZE2];\n\n  if ((fp = fopen(filename, \"r\")) == NULL) {\n    fprintf(stderr, \"Can't open table file %s\\n\", filename);\n    return FALSE;\n  }\n  tblno = 0;\n\n  while (read_text_integer(fp, &val, &termchar)) { /* read 1st element of table */\n    if (tblno >= NUM_QUANT_TBLS) {\n      fprintf(stderr, \"Too many tables in file %s\\n\", filename);\n      fclose(fp);\n      return FALSE;\n    }\n    table[0] = (unsigned int) val;\n    for (i = 1; i < DCTSIZE2; i++) {\n      if (! read_text_integer(fp, &val, &termchar)) {\n        fprintf(stderr, \"Invalid table data in file %s\\n\", filename);\n        fclose(fp);\n        return FALSE;\n      }\n      table[i] = (unsigned int) val;","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/DrKLO/Telegram/blob/45ab8f4308496e1f01026a97fcdb0d58a5274474/TMessagesProj/jni/mozjpeg/rdswitch.c#L80-L116","documentation":"The read_quant_tables function attempts to open the quantization table file specified by the -qtables filename argument. If fopen fails (returns NULL), the file does not exist or is not accessible. The function returns FALSE, signaling failure to the cjpeg caller. This is part of mozjpeg's custom quantization table loading feature, where tables are stored as plain ASCII decimal values.","triggerScenarios":"Calling cjpeg with -qtables <file> where <file> does not exist, is unreadable, or is a directory. The fopen(filename, 'r') check at the entry of read_quant_tables returns NULL.","commonSituations":"Typo in the quantization table filename; relative path from the wrong working directory; the table file was not generated or deployed; permissions issue on the table file; pointing to a directory instead of a file.","solutions":["Verify the table file exists and is readable: test -f <file> and test -r <file>.","Check the path for typos and use an absolute path if uncertain about the working directory.","Generate the quantization table file if it does not exist (it should contain 64 integers per table in plain text)."],"exampleFix":"# before\ncjpeg -qtables nonexistent.qtl image.bmp > out.jpg\n# after\ncjpeg -qtables /path/to/quant_tables.qtl image.bmp > out.jpg","handlingStrategy":"validation","validationCode":"// In C: check file accessibility before calling read_quant_tables\n#include <unistd.h>\nif (access(filename, R_OK) != 0) {\n  fprintf(stderr, \"Table file %s is not readable\\n\", filename);\n  return FALSE;\n}\nreturn read_quant_tables(cinfo, filename, force_baseline);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use access(filename, R_OK) to check readability before calling read_quant_tables.","Use absolute paths for quantization table files.","Store table files in a version-controlled directory to prevent path drift."],"tags":["filesystem","file-not-found","quantization","mozjpeg"],"backgroundTag":null,"analyzedSha":"45ab8f4308496e1f01026a97fcdb0d58a5274474","analyzedAt":"2026-08-14T05:19:30.815Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}