MCPcopy Create free account
hub / github.com/DFHack/dfhack / lodepng_mulofl

Function lodepng_mulofl

depends/lodepng/lodepng.cpp:157–160  ·  view source on GitHub ↗

Safely check if multiplying two integers will overflow (no undefined behavior, compiler removing the code, etc...) and output result. */

Source from the content-addressed store, hash-verified

155/* Safely check if multiplying two integers will overflow (no undefined
156behavior, compiler removing the code, etc...) and output result. */
157static int lodepng_mulofl(size_t a, size_t b, size_t* result) {
158 *result = a * b; /* Unsigned multiplication is well defined and safe in C90 */
159 return (a != 0 && *result / a != b);
160}
161
162#ifdef LODEPNG_COMPILE_ZLIB
163/* Safely check if a + b > c, even if overflow could happen. */

Callers 2

LodePNGBitReader_initFunction · 0.85
lodepng_pixel_overflowFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected