Skip to content

Commit 060126a

Browse files
committed
FIX: invalid MOLD on empty image
1 parent 4f16809 commit 060126a

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/core/t-image.c

+5
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,11 @@ INLINE REBCNT ARGB_To_BGR(REBCNT i)
438438

439439
// Output RGB image:
440440
size = VAL_IMAGE_LEN(value); // # pixels (from index to tail)
441+
442+
if (size == 0) {
443+
Append_Byte(mold->series, '}');
444+
return;
445+
}
441446
data = (REBCNT *)VAL_IMAGE_DATA(value);
442447
up = Prep_Uni_Series(mold, (size * 6) + ((size - 1) / 10) + 1);
443448

src/tests/units/mold-test.r3

+10
Original file line numberDiff line numberDiff line change
@@ -261,4 +261,14 @@ Rebol [
261261

262262
===end-group===
263263

264+
265+
===start-group=== "mold image!"
266+
267+
--test-- "mold empty image"
268+
--assert "make image! [0x0 #{}]" = mold make image! 0x0
269+
--assert "make image! [10x0 #{}]" = mold make image! 10x0
270+
--assert "make image! [0x10 #{}]" = mold make image! 0x10
271+
272+
===end-group===
273+
264274
~~~end-file~~~

0 commit comments

Comments
 (0)