MCPcopy Create free account
hub / github.com/abbeycode/UnrarKit / SafePPMDecodeChar

Method SafePPMDecodeChar

Libraries/unrar/unpack30.cpp:4–13  ·  view source on GitHub ↗

We use it instead of direct PPM.DecodeChar call to be sure that we reset PPM structures in case of corrupt data. It is important, because these structures can be invalid after PPM.DecodeChar returned -1.

Source from the content-addressed store, hash-verified

2// we reset PPM structures in case of corrupt data. It is important,
3// because these structures can be invalid after PPM.DecodeChar returned -1.
4inline int Unpack::SafePPMDecodeChar()
5{
6 int Ch=PPM.DecodeChar();
7 if (Ch==-1) // Corrupt PPM data found.
8 {
9 PPM.CleanUp(); // Reset possibly corrupt PPM data structures.
10 UnpBlockType=BLOCK_LZ; // Set faster and more fail proof LZ mode.
11 }
12 return(Ch);
13}
14
15
16void Unpack::Unpack29(bool Solid)

Callers

nothing calls this directly

Calls 2

DecodeCharMethod · 0.80
CleanUpMethod · 0.80

Tested by

no test coverage detected