{"record":{"id":"48ab3d635ac8b40d","repo":"mozilla/pdf.js","slug":"too-many-arguments","errorCode":null,"errorMessage":"Too many arguments","messagePattern":"Too many arguments","errorType":"exception","errorClass":"FormatError","httpStatus":null,"severity":"error","filePath":"src/core/evaluator.js","lineNumber":5473,"sourceCode":"\n        // TODO figure out how to type-check vararg functions\n        this.preprocessCommand(fn, args);\n\n        operation.fn = fn;\n        operation.args = args;\n        return true;\n      }\n      if (obj === EOF) {\n        return false; // no more commands\n      }\n      // argument\n      if (obj !== null) {\n        if (args === null) {\n          args = [];\n        }\n        args.push(obj);\n        if (args.length > 33) {\n          throw new FormatError(\"Too many arguments\");\n        }\n      }\n    }\n  }\n\n  preprocessCommand(fn, args) {\n    switch (fn | 0) {\n      case OPS.save:\n        this.stateManager.save();\n        break;\n      case OPS.restore:\n        this.stateManager.restore();\n        break;\n      case OPS.transform:\n        this.stateManager.transform(args);\n        break;\n    }\n  }","sourceCodeStart":5455,"sourceCodeEnd":5491,"githubUrl":"https://github.com/mozilla/pdf.js/blob/5903d58d58e4dd9ce6ffa3834aea8480f06b4ada/src/core/evaluator.js#L5455-L5491","documentation":"Thrown by EvaluatorPreprocessor while accumulating operands for an operator when the argument stack exceeds 33 entries without a matching operator consuming them. The PDF spec caps operands at 31 (plus margin); exceeding this indicates a malformed stream where operands pile up, typically due to missing operator tokens or corrupt numeric data. The guard prevents unbounded memory growth and infinite accumulation.","triggerScenarios":"A content stream where 34+ operands are pushed without any operator consuming them — e.g. a long run of numbers due to a missing 'm'/'l'/'scn' operator, or a corrupt stream decoded into a sea of numeric tokens. Fires during the operand-collection loop in EvaluatorPreprocessor.read().","commonSituations":"Content streams corrupted by transfer errors, decompression faults producing garbage tokens, or generators that wrote large numeric arrays without interleaving operators. Also seen when a Flate stream is mis-decoded due to upstream corruption, yielding spurious numeric tokens.","solutions":["Re-acquire the PDF (re-download, re-export) to rule out transfer corruption.","Repair with qpdf or Ghostscript to re-encode the content stream and remove corrupt tokens.","Isolate the page with per-page try/catch; render remaining pages normally.","If authoring, ensure your content-stream writer flushes operators at least every 31 operands."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await page.render({ canvasContext, viewport });\n} catch (e) {\n  if (e.name === 'FormatError' && /Too many arguments/.test(e.message)) {\n    // content stream corrupt — operand overflow\n  } else throw e;\n}","preventionTips":["Verify PDF integrity (re-download, MD5 check) to rule out transfer corruption of content streams.","Repair with qpdf or Ghostscript to re-encode content streams.","When authoring content streams, flush operators at least every 31 operands to stay within the spec cap."],"tags":["pdf","content-stream","operators","preprocessor","format-error"],"backgroundTag":null,"analyzedSha":"5903d58d58e4dd9ce6ffa3834aea8480f06b4ada","analyzedAt":"2026-08-13T02:28:27.364Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}