{"record":{"id":"518824d8a55ceb69","repo":"DrKLO/Telegram","slug":"too-many-tables-in-file-s","errorCode":null,"errorMessage":"Too many tables in file %s\n","messagePattern":"Too many tables in file (.+?)\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"TMessagesProj/jni/mozjpeg/rdswitch.c","lineNumber":105,"sourceCode":" * 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;\n    }\n#if JPEG_LIB_VERSION >= 70\n    jpeg_add_quant_table(cinfo, tblno, table, cinfo->q_scale_factor[tblno],\n                         force_baseline);\n#else\n    jpeg_add_quant_table(cinfo, tblno, table, q_scale_factor[tblno],\n                         force_baseline);","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/DrKLO/Telegram/blob/45ab8f4308496e1f01026a97fcdb0d58a5274474/TMessagesProj/jni/mozjpeg/rdswitch.c#L87-L123","documentation":"read_quant_tables reads quantization tables from a text file where each table has exactly 64 values (DCTSIZE2 = 64). The file may contain up to NUM_QUANT_TBLS tables (typically 4). If more tables are found (tblno exceeds NUM_QUANT_TBLS), the function reports an error, closes the file, and returns FALSE. This prevents writing past the available quantization table slots.","triggerScenarios":"Providing a quantization table file that contains 5 or more sets of 64 values. Each set of 64 integers counts as one table, and the tblno counter increments past NUM_QUANT_TBLS (typically 4).","commonSituations":"Concatenating multiple table files without removing extras; misunderstanding the table format and providing too many 64-value groups; generated table files that include more tables than the JPEG standard supports.","solutions":["Reduce the number of tables in the file to at most NUM_QUANT_TBLS (typically 4). Each table is 64 comma/space-separated integers.","Remove extra tables from the file and keep only the ones you need (typically 0 for luminance, 1 for chrominance).","Inspect the file and count the number of 64-value blocks to identify which to remove."],"exampleFix":"# before (5 tables of 64 values each in file.qtl)\ncjpeg -qtables file.qtl image.bmp > out.jpg\n# after (keep only 4 tables, remove the 5th block)\ncjpeg -qtables trimmed.qtl image.bmp > out.jpg","handlingStrategy":"validation","validationCode":"// Pre-validate table count: count 64-value blocks in the file\n#include <stdio.h>\nstatic int count_quant_tables(const char *filename) {\n  FILE *fp = fopen(filename, \"r\");\n  if (!fp) return -1;\n  long val; int termchar, count = 0, vals = 0;\n  while (read_text_integer(fp, &val, &termchar)) {\n    vals++;\n    if (vals % 64 == 0) count++;\n  }\n  fclose(fp);\n  return count;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Limit quantization tables to NUM_QUANT_TBLS (4) per file.","Count 64-value blocks in the file before passing it to cjpeg.","Use separate table files if you need to test different table sets."],"tags":["validation","quantization","table-overflow","mozjpeg"],"backgroundTag":null,"analyzedSha":"45ab8f4308496e1f01026a97fcdb0d58a5274474","analyzedAt":"2026-08-14T05:19:30.815Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}