Skip to content

Commit 9efea6e

Browse files
authored
Merge pull request #51 from Bennctu/sync
Fix heap-buffer-overflow in _twin_edge_fill function
2 parents 8ef78ba + ceb748f commit 9efea6e

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/pixmap.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ twin_pixmap_t *twin_pixmap_create(twin_format_t format,
2828
pixmap->height = height;
2929
twin_matrix_identity(&pixmap->transform);
3030
pixmap->clip.left = pixmap->clip.top = 0;
31-
pixmap->clip.right = pixmap->width;
31+
pixmap->clip.right = pixmap->width - 1;
3232
pixmap->clip.bottom = pixmap->height;
3333
pixmap->origin_x = pixmap->origin_y = 0;
3434
pixmap->stride = stride;
@@ -58,7 +58,7 @@ twin_pixmap_t *twin_pixmap_create_const(twin_format_t format,
5858
pixmap->height = height;
5959
twin_matrix_identity(&pixmap->transform);
6060
pixmap->clip.left = pixmap->clip.top = 0;
61-
pixmap->clip.right = pixmap->width;
61+
pixmap->clip.right = pixmap->width - 1;
6262
pixmap->clip.bottom = pixmap->height;
6363
pixmap->origin_x = pixmap->origin_y = 0;
6464
pixmap->stride = stride;
@@ -222,8 +222,8 @@ void twin_pixmap_clip(twin_pixmap_t *pixmap,
222222
pixmap->clip.left = 0;
223223
if (pixmap->clip.top < 0)
224224
pixmap->clip.top = 0;
225-
if (pixmap->clip.right > pixmap->width)
226-
pixmap->clip.right = pixmap->width;
225+
if (pixmap->clip.right > pixmap->width - 1)
226+
pixmap->clip.right = pixmap->width - 1;
227227
if (pixmap->clip.bottom > pixmap->height)
228228
pixmap->clip.bottom = pixmap->height;
229229
}
@@ -260,7 +260,7 @@ void twin_pixmap_reset_clip(twin_pixmap_t *pixmap)
260260
{
261261
pixmap->clip.left = 0;
262262
pixmap->clip.top = 0;
263-
pixmap->clip.right = pixmap->width;
263+
pixmap->clip.right = pixmap->width - 1;
264264
pixmap->clip.bottom = pixmap->height;
265265
}
266266

0 commit comments

Comments
 (0)