@@ -167,12 +167,22 @@ static void _inf_compute_surface(InfinitePrivate *priv, t_interpol* vector_field
167167 add_src = y * priv -> plugwidth + x ;
168168 ptr_pix = priv -> surface1 + add_src ;;
169169
170- /* FIXME it does buffer overread here now and then */
171-
172- color = (* (ptr_pix ) * (interpol -> weight >> 24 )
173- + * (ptr_pix + 1 ) * ((interpol -> weight & 0xFFFFFF ) >> 16 )
174- + * (ptr_pix + priv -> plugwidth ) * ((interpol -> weight & 0xFFFF ) >> 8 )
175- + * (ptr_pix + priv -> plugwidth + 1 ) * (interpol -> weight & 0xFF )) >> 8 ;
170+ const uint8_t * ptr_pix_end = priv -> surface1 + (priv -> plugwidth * priv -> plugheight );
171+
172+ const uint8_t neighbor_right = (ptr_pix + 1 >= ptr_pix_end )
173+ ? 0
174+ : * (ptr_pix + 1 );
175+ const uint8_t neighbor_below = (ptr_pix + priv -> plugwidth >= ptr_pix_end )
176+ ? 0
177+ : * (ptr_pix + priv -> plugwidth );
178+ const uint8_t neighbor_right_below = (ptr_pix + priv -> plugwidth + 1 >= ptr_pix_end )
179+ ? 0
180+ : * (ptr_pix + priv -> plugwidth + 1 );
181+
182+ color = (* (ptr_pix ) * (interpol -> weight >> 24 )
183+ + neighbor_right * ((interpol -> weight & 0xFFFFFF ) >> 16 )
184+ + neighbor_below * ((interpol -> weight & 0xFFFF ) >> 8 )
185+ + neighbor_right_below * (interpol -> weight & 0xFF )) >> 8 ;
176186/*
177187 color= (*(ptr_pix) // * (interpol->weight >> 24)
178188 +*(ptr_pix + 1) // * ((interpol->weight & 0xFFFFFF) >> 16)
@@ -431,9 +441,7 @@ void _inf_init_display(InfinitePrivate *priv)
431441 priv -> plugwidth = priv -> plugwidth ;
432442 priv -> plugheight = priv -> plugheight ;
433443
434- /* Yes we alloc a bit more because there is some odd race buffer overrun which i (the porter)
435- * am to lazy to debug */
436- allocsize = (priv -> plugwidth * priv -> plugheight ) + (priv -> plugwidth * 2 );
444+ allocsize = priv -> plugwidth * priv -> plugheight ;
437445
438446 priv -> surface1 = (uint8_t * ) visual_mem_malloc0 (allocsize );
439447 priv -> surface2 = (uint8_t * ) visual_mem_malloc0 (allocsize );
0 commit comments