phoboslab / pl_mpeg

Single file C library for decoding MPEG1 Video and MP2 Audio
799 stars 58 forks source link

UBSan Triggered #41

Closed GithubPrankster closed 1 month ago

GithubPrankster commented 4 months ago

At line 3178:

    else if (motion < ((-fscale) << 4)) {

And at line 3366:

    level <<= 1;

When using -fsanitize=undefined.

Changing these to else if (motion < (-(fscale << 4))) { and level = (int)((unsigned int)level << 1); seems to work and doesn't present any issues as far as I can tell.

phoboslab commented 1 month ago

Fixed with https://github.com/phoboslab/pl_mpeg/pull/43