Code Monkey home page Code Monkey logo

Comments (9)

mackron avatar mackron commented on June 3, 2024 1

I've updated the master branch with this change. Version 0.6.37.

from dr_libs.

mackron avatar mackron commented on June 3, 2024

Thanks. This is a weird one because there are literal asserts in there to account for this like you mentioned. It feels like for some reason the compilers are not recognizing those asserts:

DRMP3_ASSERT(pMP3->pData != NULL);
DRMP3_ASSERT(pMP3->dataCapacity > 0);

pcmFramesRead = drmp3dec_decode_frame(&pMP3->decoder, pMP3->pData + pMP3->dataConsumed, (int)pMP3->dataSize, pPCMFrames, &info);    /* <-- Safe size_t -> int conversion thanks to the check above. */

I'm almost wondering if maybe I just do a normal run-time check for pData being null and just returning 0. Have you by chance tried that to see if it cleans up that warning? I don't like the idea of modifying drmp3dec_decode_frame() simply because that code is from minimp3 which I'm not fully intimate with.

I'm not really the biggest fan of the nonnull thing because it just feels a bit hacky, and I'd be nice to avoid compiler-specific stuff if possible. But that said, if I need to do a compiler-specific thing so be it.

from dr_libs.

bwrsandman avatar bwrsandman commented on June 3, 2024

I tried what you said and naively returned 0. This seems to silence the error.

It also complains about this move operation. https://github.com/mackron/dr_libs/blob/master/dr_mp3.h#L2725

from dr_libs.

mackron avatar mackron commented on June 3, 2024

I've pushed a potential fix to clean up this warning to the dev branch. Are you able to try that?

from dr_libs.

bwrsandman avatar bwrsandman commented on June 3, 2024

That seems to have fixed it.

from dr_libs.

mackron avatar mackron commented on June 3, 2024

OK, that's good to hear. The fact that the static analyzer is recognizing the runtime check indicates to me that it's not detecting or recognizing the assert for some reason. In any case I'll get this released shortly.

from dr_libs.

bwrsandman avatar bwrsandman commented on June 3, 2024

Could be due to NDEBUG

from dr_libs.

bwrsandman avatar bwrsandman commented on June 3, 2024

I've updated dr_wav.h and theres this new one that popped up.

warning: Array access (from variable 'pBufferOut') results in a null pointer dereference [clang-analyzer-core.NullDereference]

                ((drwav_uint8*)pBufferOut)[iSample] += 128;
                                                    ^
Additional context

src/Audio/WavAudioDecoder.cpp:31: Calling 'drwav_read_pcm_frames_s16'

	[[maybe_unused]] auto framesRead = drwav_read_pcm_frames_s16(&_wav, frameCount, buffer.data());
                                    ^

externals/dr_libs/dr_wav.h:6788: 'pWav' is not equal to NULL

    if (pWav == NULL || framesToRead == 0) {
        ^

externals/dr_libs/dr_wav.h:6788: Left side of '||' is false

    if (pWav == NULL || framesToRead == 0) {
        ^

externals/dr_libs/dr_wav.h:6788: Assuming 'framesToRead' is not equal to 0

    if (pWav == NULL || framesToRead == 0) {
                        ^

externals/dr_libs/dr_wav.h:6788: Taking false branch

    if (pWav == NULL || framesToRead == 0) {
    ^

externals/dr_libs/dr_wav.h:6792: Assuming 'pBufferOut' is equal to NULL

    if (pBufferOut == NULL) {
        ^

externals/dr_libs/dr_wav.h:6792: Taking true branch

    if (pBufferOut == NULL) {
    ^

externals/dr_libs/dr_wav.h:6793: Passing null pointer value via 3rd parameter 'pBufferOut'

        return drwav_read_pcm_frames(pWav, framesToRead, NULL);
                                                         ^

/usr/lib/llvm-15/lib/clang/15.0.7/include/stddef.h:83: expanded from macro 'NULL'

#    define NULL __null
                 ^

externals/dr_libs/dr_wav.h:6793: Calling 'drwav_read_pcm_frames'

        return drwav_read_pcm_frames(pWav, framesToRead, NULL);
               ^

externals/dr_libs/dr_wav.h:5757: Taking false branch

    if (drwav_is_container_be(pWav->container)) {
    ^

externals/dr_libs/dr_wav.h:5775: Taking true branch

    if (drwav__is_little_endian()) {
    ^

externals/dr_libs/dr_wav.h:5787: Assuming field 'container' is equal to drwav_container_aiff

        if (pWav->container == drwav_container_aiff && pWav->bitsPerSample == 8 && pWav->aiff.isUnsigned == DRWAV_FALSE) {
            ^

externals/dr_libs/dr_wav.h:5787: Left side of '&&' is true

        if (pWav->container == drwav_container_aiff && pWav->bitsPerSample == 8 && pWav->aiff.isUnsigned == DRWAV_FALSE) {
            ^

externals/dr_libs/dr_wav.h:5787: Assuming field 'bitsPerSample' is equal to 8

        if (pWav->container == drwav_container_aiff && pWav->bitsPerSample == 8 && pWav->aiff.isUnsigned == DRWAV_FALSE) {
                                                       ^

externals/dr_libs/dr_wav.h:5787: Left side of '&&' is true

        if (pWav->container == drwav_container_aiff && pWav->bitsPerSample == 8 && pWav->aiff.isUnsigned == DRWAV_FALSE) {
            ^

externals/dr_libs/dr_wav.h:5787: Assuming field 'isUnsigned' is equal to DRWAV_FALSE

        if (pWav->container == drwav_container_aiff && pWav->bitsPerSample == 8 && pWav->aiff.isUnsigned == DRWAV_FALSE) {
                                                                                   ^

externals/dr_libs/dr_wav.h:5787: Taking true branch

        if (pWav->container == drwav_container_aiff && pWav->bitsPerSample == 8 && pWav->aiff.isUnsigned == DRWAV_FALSE) {
        ^

externals/dr_libs/dr_wav.h:5790: Assuming the condition is true

            for (iSample = 0; iSample < framesRead * pWav->channels; iSample += 1) {
                              ^

externals/dr_libs/dr_wav.h:5790: Loop condition is true. Entering loop body

            for (iSample = 0; iSample < framesRead * pWav->channels; iSample += 1) {
            ^

externals/dr_libs/dr_wav.h:5791: Array access (from variable 'pBufferOut') results in a null pointer dereference

                ((drwav_uint8*)pBufferOut)[iSample] += 128;
                                                    ^

from dr_libs.

mackron avatar mackron commented on June 3, 2024

Thanks. That's a genuine bug. I've gone ahead and fixed that in the dev branch.

from dr_libs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.