xbmc/xbmc — pull request #4518 by astiob (2014-04-04 19:51:11+00:00)
Title: Make convert_quad cleaner and fix subtitle corruption with new libass

For a screenshot of the corruption, see OpenELEC/OpenELEC.tv#3059. In that particular case, there are three ASS_Images with width 1773, 1777 and 1777. The sum is 5327 (or with padding, 5330), which is larger than the maximum texture width of 2048. The current code halves it to 2663 (2665) and then halves it again to 1331 (1332). But 1331 and 1332 pixels are not enough to fit in a 1777-pixel bitmap. The third loop detects this, but the only action it takes is skip a line in the texture; it then proceeds to memcpy the 1777-pixels-wide bitmap into the 1331-pixels-wide buffer. The result is a visual effect as shown in the screenshot and possibly some corrupted memory.