{"record":{"id":"62e471b577557d9a","repo":"DrKLO/Telegram","slug":"failed-to-create-the-decoder-s-n","errorCode":null,"errorMessage":"Failed to create the decoder: %s\\n","messagePattern":"Failed to create the decoder: (.+?)\\\\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"TMessagesProj/jni/opus/celt/opus_custom_demo.c","lineNumber":115,"sourceCode":"   if (!fout)\n   {\n      fprintf (stderr, \"Could not open output file %s\\n\", argv[argc-1]);\n      fclose(fin);\n      return 1;\n   }\n\n   enc = opus_custom_encoder_create(mode, channels, &err);\n   if (err != 0)\n   {\n      fprintf(stderr, \"Failed to create the encoder: %s\\n\", opus_strerror(err));\n      fclose(fin);\n      fclose(fout);\n      return 1;\n   }\n   dec = opus_custom_decoder_create(mode, channels, &err);\n   if (err != 0)\n   {\n      fprintf(stderr, \"Failed to create the decoder: %s\\n\", opus_strerror(err));\n      fclose(fin);\n      fclose(fout);\n      return 1;\n   }\n   opus_custom_decoder_ctl(dec, OPUS_GET_LOOKAHEAD(&skip));\n\n   if (argc>7)\n   {\n      complexity=atoi(argv[5]);\n      opus_custom_encoder_ctl(enc,OPUS_SET_COMPLEXITY(complexity));\n   }\n\n   in = (opus_int16*)malloc(frame_size*channels*sizeof(opus_int16));\n   out = (opus_int16*)malloc(frame_size*channels*sizeof(opus_int16));\n\n   while (!feof(fin))\n   {\n      int ret;","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/DrKLO/Telegram/blob/45ab8f4308496e1f01026a97fcdb0d58a5274474/TMessagesProj/jni/opus/celt/opus_custom_demo.c#L97-L133","documentation":"opus_custom_decoder_create(mode, channels, &err) set err non-zero — the decoder object could not be created. The encoder was created successfully and is implicitly leaked here (no opus_custom_encoder_destroy on this error path). Both file handles are closed.","triggerScenarios":"err != OPUS_OK. Same shape as the encoder error: OPUS_BAD_ARG for invalid channels, or allocation failure. channels must match the encoder's channel count for the round-trip demo to be valid.","commonSituations":"channels mismatch with the mode; channels value 0 or >2 from a bad CLI arg; memory pressure; the mode parameters being incompatible with decoder construction.","solutions":["Validate channels is 1 or 2 and matches what was used for the encoder.","Inspect opus_strerror(err) for the concrete cause.","Destroy the encoder (opus_custom_encoder_destroy(enc)) on this path to avoid a leak.","Ensure adequate free memory for the decoder allocation."],"exampleFix":"// before\ndec = opus_custom_decoder_create(mode, channels, &err);\nif (err != 0) { fprintf(stderr, \"Failed to create the decoder: %s\\n\", opus_strerror(err)); fclose(fin); fclose(fout); return 1; }\n\n// after: also free the encoder\ndec = opus_custom_decoder_create(mode, channels, &err);\nif (err != 0) { fprintf(stderr, \"Failed to create the decoder: %s\\n\", opus_strerror(err)); opus_custom_encoder_destroy(enc); fclose(fin); fclose(fout); return 1; }","handlingStrategy":"validation","validationCode":"// Validate channels and destroy the encoder on failure.\nif (channels != 1 && channels != 2) { fprintf(stderr, \"channels must be 1 or 2\\n\"); return 1; }\ndec = opus_custom_decoder_create(mode, channels, &err);\nif (err != 0) { opus_custom_encoder_destroy(enc); fprintf(stderr, \"Failed to create the decoder: %s\\n\", opus_strerror(err)); fclose(fin); fclose(fout); return 1; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use the same channels value as the encoder.","Call opus_custom_encoder_destroy(enc) on this error path to avoid a leak.","Inspect opus_strerror(err) for the concrete cause."],"tags":["opus","decoder","bad-arg","resource-leak","channels","audio","c"],"backgroundTag":null,"analyzedSha":"45ab8f4308496e1f01026a97fcdb0d58a5274474","analyzedAt":"2026-08-14T05:19:30.815Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}