SDL_FillRect does not play nicely with paletted surfaces

I’m having the same problem as previously discussed in this thread: [SDL_FillRect() causing access error only with certain input]. It suggests that the problem could be fixable by rebuilding SDL2.lib from source.

I’m not familiar with building libraries. Can anyone direct me on how to do that using Code::Blocks and mingw32? Failing that, any insight into build settings that I need in my project to make my app compatible with the existing library?