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

Function stbi__parse_uncompressed_block

Source/Utils/stb_image.h:4408–4435  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4406}
4407
4408static int stbi__parse_uncompressed_block(stbi__zbuf *a)
4409{
4410 stbi_uc header[4];
4411 int len,nlen,k;
4412 if (a->num_bits & 7)
4413 stbi__zreceive(a, a->num_bits & 7); // discard
4414 // drain the bit-packed data into header
4415 k = 0;
4416 while (a->num_bits > 0) {
4417 header[k++] = (stbi_uc) (a->code_buffer & 255); // suppress MSVC run-time check
4418 a->code_buffer >>= 8;
4419 a->num_bits -= 8;
4420 }
4421 if (a->num_bits < 0) return stbi__err("zlib corrupt","Corrupt PNG");
4422 // now fill header the normal way
4423 while (k < 4)
4424 header[k++] = stbi__zget8(a);
4425 len = header[1] * 256 + header[0];
4426 nlen = header[3] * 256 + header[2];
4427 if (nlen != (len ^ 0xffff)) return stbi__err("zlib corrupt","Corrupt PNG");
4428 if (a->zbuffer + len > a->zbuffer_end) return stbi__err("read past buffer","Corrupt PNG");
4429 if (a->zout + len > a->zout_end)
4430 if (!stbi__zexpand(a, a->zout, len)) return 0;
4431 memcpy(a->zout, a->zbuffer, len);
4432 a->zbuffer += len;
4433 a->zout += len;
4434 return 1;
4435}
4436
4437static int stbi__parse_zlib_header(stbi__zbuf *a)
4438{

Callers 1

stbi__parse_zlibFunction · 0.85

Calls 4

stbi__zreceiveFunction · 0.85
stbi__errFunction · 0.85
stbi__zget8Function · 0.85
stbi__zexpandFunction · 0.85

Tested by

no test coverage detected