{"record":{"id":"f7964e5119c08c6b","repo":"Tencent/matrix","slug":"invalidparamexception","errorCode":null,"errorMessage":"InvalidParamException","messagePattern":"InvalidParamException","errorType":"exception","errorClass":"InvalidParamException","httpStatus":null,"severity":"error","filePath":"matrix/matrix-android/matrix-backtrace/src/main/cpp/external/libunwindstack/deps/liblzma/CS/7zip/Compress/LZMA/LzmaDecoder.cs","lineNumber":352,"sourceCode":"\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif (rep0 == 0xFFFFFFFF)\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\tthrow new DataErrorException();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tm_OutWindow.CopyBlock(rep0, len);\n\t\t\t\t\t\tnowPos64 += len;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tm_OutWindow.Flush();\n\t\t\tm_OutWindow.ReleaseStream();\n\t\t\tm_RangeDecoder.ReleaseStream();\n\t\t}\n\n\t\tpublic void SetDecoderProperties(byte[] properties)\n\t\t{\n\t\t\tif (properties.Length < 5)\n\t\t\t\tthrow new InvalidParamException();\n\t\t\tint lc = properties[0] % 9;\n\t\t\tint remainder = properties[0] / 9;\n\t\t\tint lp = remainder % 5;\n\t\t\tint pb = remainder / 5;\n\t\t\tif (pb > Base.kNumPosStatesBitsMax)\n\t\t\t\tthrow new InvalidParamException();\n\t\t\tUInt32 dictionarySize = 0;\n\t\t\tfor (int i = 0; i < 4; i++)\n\t\t\t\tdictionarySize += ((UInt32)(properties[1 + i])) << (i * 8);\n\t\t\tSetDictionarySize(dictionarySize);\n\t\t\tSetLiteralProperties(lp, lc);\n\t\t\tSetPosBitsProperties(pb);\n\t\t}\n\n\t\tpublic bool Train(System.IO.Stream stream)\n\t\t{\n\t\t\t_solid = true;\n\t\t\treturn m_OutWindow.Train(stream);","sourceCodeStart":334,"sourceCodeEnd":370,"githubUrl":"https://github.com/Tencent/matrix/blob/3b8293bd65d47eeea7caf1f32a3a5d4d5eab60e7/matrix/matrix-android/matrix-backtrace/src/main/cpp/external/libunwindstack/deps/liblzma/CS/7zip/Compress/LZMA/LzmaDecoder.cs#L334-L370","documentation":"Decoder.SetDecoderProperties validates the 5-byte LZMA properties header. The first check requires at least 5 bytes; a shorter array cannot encode lc/lp/pb plus the 4-byte dictionary size, so InvalidParamException is thrown.","triggerScenarios":"Calling decoder.SetDecoderProperties(byte[]) with an array of length 0-4, e.g. reading a header from a truncated file or passing an empty/default array.","commonSituations":"Hard-coding new byte[4] by mistake, reading a 5-byte header from a stream that hit EOF, or forgetting the 5-byte props prefix that .lzma-alone files require.","solutions":["Pass the real 5 property bytes read from the compressed stream (or the same values the encoder wrote)","Validate properties != null && properties.Length >= 5 before calling SetDecoderProperties","If the source lacks a header, generate properties yourself and write them to the output when compressing so both sides agree"],"exampleFix":"// before\ndecoder.SetDecoderProperties(headerBytes); // headerBytes may be short\n\n// after\nif (headerBytes == null || headerBytes.Length < 5)\n    throw new IOException(\"Missing or truncated LZMA properties header\");\ndecoder.SetDecoderProperties(headerBytes);","handlingStrategy":"validation","validationCode":"// C#\nbool HasValidLzmaHeader(byte[] p) => p != null && p.Length >= 5;\nif (!HasValidLzmaHeader(props)) throw new IOException(\"LZMA props header must be 5 bytes\");","typeGuard":"bool HasValidLzmaHeader(byte[] p) => p != null && p.Length >= 5;","tryCatchPattern":"// C#\ntry {\n    decoder.SetDecoderProperties(props);\n} catch (InvalidParamException) {\n    throw new InvalidDataException(\"LZMA properties header missing or shorter than 5 bytes\");\n}","preventionTips":["Read exactly 5 bytes for the props header and check the read count","When compressing, always write the 5-byte header to the output stream","Guard with p.Length >= 5 before calling SetDecoderProperties"],"tags":["csharp","compression","lzma","argument-validation"],"backgroundTag":"invalid-argument-value","analyzedSha":"3b8293bd65d47eeea7caf1f32a3a5d4d5eab60e7","analyzedAt":"2026-09-08T08:01:39.722Z","contentChangedAt":"2026-09-08T08:01:39.722Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}