mupen64plus / mupen64plus-video-glide64mk2

Video plugin for Mupen64Plus 2.0 based on 10th anniversary release code from gonetz
28 stars 37 forks source link

potential issue in TxQuantize.cpp #100

Closed bugfood closed 6 years ago

bugfood commented 6 years ago

I noticed that in TxQuantize.cpp in TxQuantize::quantize, there is a section of code with the relevant parts:

for (i = 0; i < numcore - 1; i++) {
    ...
    if (i == numcore-1)
        ...
    ...
    thrd[i] = SDL_CreateThread(QuantizeThreadFunc, "quantizer", &params[i]);
    ...
}
for (i = 0; i < numcore; i++) {
    SDL_WaitThread(thrd[i], NULL);
}    

Should the first for loop have i < numcore?

I think the following are currently true:

  1. The conditional in the body of the loop won't ever succeed.
  2. SDL_WaitThread will get an uninitialized value.

I don't know how to exercise this function, but it didn't quite look right to me.

Thanks, Corey

richard42 commented 6 years ago

Definitely a bug. It looks to me like the "numcore - 1" in the for loop statement should just be "numcore"

bugfood commented 6 years ago

Ok, that's what I thought. Changing it is trivial, though I don't know how to test it. If you want this PR...

https://github.com/mupen64plus/mupen64plus-video-glide64mk2/pull/101