Skip to content

Commit f4137f5

Browse files
Bennctuweihsinyeh
authored andcommitted
Fix display issue and heap-buffer-overflow
The issue with the display not showing the rightmost pixel of the icon and clock is caused by commit ceb748f. Therefore, in ceb748f, solving the heap-buffer-overflow issue by using width - 1 is incorrect. We revert the changes from commit ceb748f and instead perform a check in `_span_fill()`. The last pixel may have already been covered when processing the middle pixels. To address this, an additional condition is added when processing the last pixel to ensure it is not covered by the middle pixels, allowing us to handle the last pixel separately. See #49 See #51 Close #78
1 parent 501453e commit f4137f5

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/pixmap.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ twin_pixmap_t *twin_pixmap_create(twin_format_t format,
3737
pixmap->height = height;
3838
twin_matrix_identity(&pixmap->transform);
3939
pixmap->clip.left = pixmap->clip.top = 0;
40-
pixmap->clip.right = pixmap->width - 1;
40+
pixmap->clip.right = pixmap->width;
4141
pixmap->clip.bottom = pixmap->height;
4242
pixmap->origin_x = pixmap->origin_y = 0;
4343
pixmap->stride = stride;
@@ -67,7 +67,7 @@ twin_pixmap_t *twin_pixmap_create_const(twin_format_t format,
6767
pixmap->height = height;
6868
twin_matrix_identity(&pixmap->transform);
6969
pixmap->clip.left = pixmap->clip.top = 0;
70-
pixmap->clip.right = pixmap->width - 1;
70+
pixmap->clip.right = pixmap->width;
7171
pixmap->clip.bottom = pixmap->height;
7272
pixmap->origin_x = pixmap->origin_y = 0;
7373
pixmap->stride = stride;
@@ -231,8 +231,8 @@ void twin_pixmap_clip(twin_pixmap_t *pixmap,
231231
pixmap->clip.left = 0;
232232
if (pixmap->clip.top < 0)
233233
pixmap->clip.top = 0;
234-
if (pixmap->clip.right > pixmap->width - 1)
235-
pixmap->clip.right = pixmap->width - 1;
234+
if (pixmap->clip.right > pixmap->width)
235+
pixmap->clip.right = pixmap->width;
236236
if (pixmap->clip.bottom > pixmap->height)
237237
pixmap->clip.bottom = pixmap->height;
238238
}
@@ -269,7 +269,7 @@ void twin_pixmap_reset_clip(twin_pixmap_t *pixmap)
269269
{
270270
pixmap->clip.left = 0;
271271
pixmap->clip.top = 0;
272-
pixmap->clip.right = pixmap->width - 1;
272+
pixmap->clip.right = pixmap->width;
273273
pixmap->clip.bottom = pixmap->height;
274274
}
275275

src/poly.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ static void _span_fill(twin_pixmap_t *pixmap,
213213
}
214214

215215
/* last pixel */
216-
if (right & TWIN_POLY_MASK) {
216+
if (right & TWIN_POLY_MASK && x != right) {
217217
w = 0;
218218
col = 0;
219219
while (x < right) {

0 commit comments

Comments
 (0)