mackron / dr_libs

Audio decoding libraries for C/C++, each in a single source file.
Other
1.24k stars 205 forks source link

dr_wav (0.13.3): Coverity flagged Division or modulo by zero (CWE-369) #215

Closed kcgen closed 2 years ago

kcgen commented 2 years ago

"The program will have undefined behavior, likely a crash. In drwav_seek_to_pcm_frame: Division or modulo by zero results in undefined behavior. (CWE-369)"

2021-11-28_06-45

mackron commented 2 years ago

Fix in the dev branch. I don't think this was an error in practice because I already have a guard in place at initialization time:

/* The number of bytes per frame must be known. If not, it's an invalid file and not decodable. */
if (drwav_get_bytes_per_pcm_frame(pWav) == 0) {
    return DRWAV_FALSE;
}

In any case, I've added some checks in the relevant places and I think these ones should be cleaned up now.

mackron commented 2 years ago

These fixes have been released.