MCPcopy Create free account
hub / github.com/OpenFodder/openfodder / stbi__parse_zlib_header

Function stbi__parse_zlib_header

Source/Utils/stb_image.h:4437–4449  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4435}
4436
4437static int stbi__parse_zlib_header(stbi__zbuf *a)
4438{
4439 int cmf = stbi__zget8(a);
4440 int cm = cmf & 15;
4441 /* int cinfo = cmf >> 4; */
4442 int flg = stbi__zget8(a);
4443 if (stbi__zeof(a)) return stbi__err("bad zlib header","Corrupt PNG"); // zlib spec
4444 if ((cmf*256+flg) % 31 != 0) return stbi__err("bad zlib header","Corrupt PNG"); // zlib spec
4445 if (flg & 32) return stbi__err("no preset dict","Corrupt PNG"); // preset dictionary not allowed in png
4446 if (cm != 8) return stbi__err("bad compression","Corrupt PNG"); // DEFLATE required for png
4447 // window = 1 << (8 + cinfo)... but who cares, we fully buffer output
4448 return 1;
4449}
4450
4451static const stbi_uc stbi__zdefault_length[STBI__ZNSYMS] =
4452{

Callers 1

stbi__parse_zlibFunction · 0.85

Calls 3

stbi__zget8Function · 0.85
stbi__zeofFunction · 0.85
stbi__errFunction · 0.85

Tested by

no test coverage detected