xbmc/xbmc — pull request #3188 by popcornmix (2013-09-02 23:09:10+00:00)
Title: [settings] Fix memory corruption caused by resolution sorting

This is possibly the most subtle bug I've seen.
What I've seen over last couple of weeks is random memory corruption
failures when browsing the settings/video output window.

I tracked it down to the sort function in CWinSystemBase::ScreenResolutions.
But why? Everything looked fine.

Eventually spotted it. The compare function doesn't obey strict weak ordering.
std::sort considers a reasonable response to that is to corrupt memory.

Here's a description from someone else who hit a similar bug:
http://schneide.wordpress.com/2010/11/01/bug-hunting-fun-with-stdsort/