diff --git a/ChangeLog b/ChangeLog index 6290ced23..afba3cb0d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2008-10-20 Neil Roberts + + Bug 1043 - COGL calls glTexSubImage2D() with out-of-bounds + values (SIGSEGV) + + * clutter/cogl/gl/cogl-texture.c + (_cogl_texture_upload_subregion_to_gl): When iterating over the + slices, discard ones that don't intersect immediatly otherwise it + will call glTexSubImage2D with a negative width/height and then + move the source position incorrectly. Thanks to Gwenole + Beauchesne. + 2008-10-20 Emmanuele Bassi * clutter/clutter-color.h: Declare clutter_color_new() in the diff --git a/clutter/cogl/gl/cogl-texture.c b/clutter/cogl/gl/cogl-texture.c index 101839e59..b4d8e7adc 100644 --- a/clutter/cogl/gl/cogl-texture.c +++ b/clutter/cogl/gl/cogl-texture.c @@ -395,6 +395,13 @@ _cogl_texture_upload_subregion_to_gl (CoglTexture *tex, _cogl_span_iter_next (&y_iter), source_y += inter_h ) { + /* Discard slices out of the subregion early */ + if (!y_iter.intersects) + { + inter_h = 0; + continue; + } + /* Iterate horizontal spans */ for (source_x = src_x, _cogl_span_iter_begin (&x_iter, tex->slice_x_spans, @@ -406,6 +413,13 @@ _cogl_texture_upload_subregion_to_gl (CoglTexture *tex, _cogl_span_iter_next (&x_iter), source_x += inter_w ) { + /* Discard slices out of the subregion early */ + if (!x_iter.intersects) + { + inter_w = 0; + continue; + } + /* Pick intersection width and height */ inter_w = CLUTTER_FIXED_TO_INT (x_iter.intersect_end - x_iter.intersect_start);