Patch proposed by Bofa. Fixes: cairo/cairo#317 Reviewed-by: Bryce Harrington <bryce@bryceharrington.org>