Skip to content

Commit 03e7afb

Browse files
64-bitmanchrisbra
authored andcommitted
patch 9.2.1167: Compiler warnings in image_sixel.c
Problem: Compiler warnings in image_sixel.c (Tony Mechelynck, after v9.2.1161) Solution: Make sixel_image8_crop() return success/error status (Foxe Chen). related: #21234 closes: #21436 Signed-off-by: Foxe Chen <[email protected]> Signed-off-by: Christian Brabandt <[email protected]>
1 parent 1992e43 commit 03e7afb

2 files changed

Lines changed: 13 additions & 5 deletions

File tree

‎src/image_sixel.c‎

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -522,9 +522,10 @@ sixel_image8_clear(sixel_image8_T *simg)
522522
* stride. x/y/w/h are clamped to src's bounds, so a partially or fully
523523
* out-of-range rectangle is silently shrunk rather than reading out of bounds;
524524
* a rectangle with no overlap at all yields a zero-sized view (width==0 or
525-
* height==0), which sixel_encode_view() rejects.
525+
* height==0), which sixel_encode_view() rejects. Returns OK on success and FAIL
526+
* on failure.
526527
*/
527-
static void
528+
static int
528529
sixel_image8_crop(
529530
sixel_image8_T *src,
530531
int x,
@@ -536,7 +537,7 @@ sixel_image8_crop(
536537
int x0, y0, x1, y1; // clamped rectangle, half-open [x0,x1) x [y0,y1)
537538

538539
if (src == NULL || out == NULL)
539-
return;
540+
return FAIL;
540541

541542
x0 = x < 0 ? 0 : x;
542543
y0 = y < 0 ? 0 : y;
@@ -551,6 +552,9 @@ sixel_image8_crop(
551552
if (y1 < y0)
552553
y1 = y0;
553554

555+
if (x1 <= x0 || y1 <= y0)
556+
return FAIL;
557+
554558
out->stride = src->width;
555559
out->idx = (x1 > x0 && y1 > y0)
556560
? src->idx + (size_t)y0 * src->width + x0
@@ -559,6 +563,8 @@ sixel_image8_crop(
559563
out->height = y1 - y0;
560564
out->pal = src->pal;
561565
out->npal = src->npal;
566+
567+
return OK;
562568
}
563569

564570
/*
@@ -901,8 +907,8 @@ image_placement_sixel_draw(image_placement_T *place)
901907

902908
image_placement_subrect(place, rect, &row, &col, &x, &y, &w, &h, false);
903909

904-
sixel_image8_crop(&ictx->image8, x, y, w, h, &view);
905-
if (sixel_encode_view(&view, seq) == FAIL)
910+
if (sixel_image8_crop(&ictx->image8, x, y, w, h, &view) == FAIL
911+
|| sixel_encode_view(&view, seq) == FAIL)
906912
continue;
907913

908914
windgoto(row, col);

‎src/version.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -743,6 +743,8 @@ static char *(features[]) =
743743

744744
static int included_patches[] =
745745
{ /* Add new patch number below this line */
746+
/**/
747+
1167,
746748
/**/
747749
1166,
748750
/**/

0 commit comments

Comments
 (0)