Blend2D

BUG OF THE MONTH | An always-false expression

V547 Expression ‘h == 0’ is always false. jpegcodec.cpp 252

BLResult blJpegDecoderImplProcessMarker(....) noexcept {
  uint32_t h = blMemReadU16uBE(p + 1);
  // ....
  if (h == 0)
    return blTraceError(BL_ERROR_JPEG_UNSUPPORTED_FEATURE);
  // ....
  impl->delayedHeight = (h == 0); // <=
  // ....
}

In this code fragment, the result of the blMemReadU16uBE function call is assigned to the h variable. Then if the h == 0 check is true, we exit from the function’s body. During initialization impl->delayedHeight, the h variable has non-zero value. Thus, impl->delayedHeight is false.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.