Skip to content

Commit

Permalink
Merge branch 'release-1.8-hotfixes' into release-1.8
Browse files Browse the repository at this point in the history
  • Loading branch information
saitoha committed Dec 23, 2019
2 parents 2319c75 + 2a319ce commit 020083b
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 34 deletions.
7 changes: 2 additions & 5 deletions Makefile.am
Expand Up @@ -34,10 +34,7 @@ valgrind: all
grep "indirectly lost: 0 bytes in 0 blocks" valgrind.log

coveralls:
coveralls -e sixel_orig -e include -e m4 \
-e stb_image.h -e stb_image_write.h
coveralls -e config.h -e stb_image.h -e stb_image_write.h -e examples -e include -e perl -e php -e ruby -e wic

coveralls-dryrun: test
coveralls -e sixel_orig -e include -e m4 \
-e stb_image.h -e stb_image_write.h \
--dryrun
coveralls -e config.h -e stb_image.h -e stb_image_write.h -e examples -e include -e perl -e php -e ruby -e wic --dryrun
4 changes: 2 additions & 2 deletions Makefile.in
Expand Up @@ -192,8 +192,8 @@ CTAGS = ctags
CSCOPE = cscope
am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/config.h.in \
$(srcdir)/libsixel.pc.in $(srcdir)/package.json.in.in \
ChangeLog NEWS compile config.guess config.sub install-sh \
ltmain.sh missing py-compile
ChangeLog NEWS compile config.guess config.sub depcomp \
install-sh ltmain.sh missing py-compile
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
distdir = $(PACKAGE)-$(VERSION)
top_distdir = $(distdir)
Expand Down
6 changes: 3 additions & 3 deletions converters/Makefile.am
Expand Up @@ -84,10 +84,10 @@ if WANT_IMG2SIXEL
@echo '[test4] conversion options'
$(WINE) ./img2sixel $(top_srcdir)/images/snake.jpg -datkinson -flum -saverage | $(WINE) ./img2sixel | tee snake.sixel
$(WINE) ./img2sixel -w50% -h150% -dfs -Bblue -thls -shistogram < $(top_srcdir)/images/snake.jpg | tee snake2.sixel
$(WINE) ./img2sixel -w2100 -h2100 -djajuni -bxterm256 -o snake3.sixel < $(top_srcdir)/images/snake.jpg
$(WINE) ./img2sixel -w210 -h210 -djajuni -bxterm256 -o snake3.sixel < $(top_srcdir)/images/snake.jpg
$(WINE) ./img2sixel -w105% -h100 -B\#000000000 -rnearest < $(top_srcdir)/images/snake.gif
$(WINE) ./img2sixel -7 -sauto -w100 -rgaussian -qauto -dburkes -tauto $(top_srcdir)/images/snake.tga
$(WINE) ./img2sixel -p300 -8 -scenter -Brgb:0/f/A -h100 -qfull -rhanning -dstucki -thls $(top_srcdir)/images/snake.tiff
$(WINE) ./img2sixel -p200 -8 -scenter -Brgb:0/f/A -h100 -qfull -rhanning -dstucki -thls $(top_srcdir)/images/snake.tiff
$(WINE) ./img2sixel -8 -qauto -thls -e $(top_srcdir)/images/snake.pgm
$(WINE) ./img2sixel -8 -m $(top_srcdir)/images/map8-palette.png -Esize $(top_srcdir)/images/snake.ppm
$(WINE) ./img2sixel -7 -m $(top_srcdir)/images/map16-palette.png -Efast $(top_srcdir)/images/snake.jpg
Expand Down Expand Up @@ -129,7 +129,7 @@ if WANT_IMG2SIXEL
$(WINE) ./img2sixel -p 1 -h100 -n1 $(top_srcdir)/images/snake.jpg && printf '\033[*1z'
$(WINE) ./img2sixel -e -h140 -rlanczos4 -P $(top_srcdir)/images/snake.jpg
$(WINE) ./img2sixel -e -i -P $(top_srcdir)/images/snake.jpg > /dev/null
$(WINE) ./img2sixel -w2047 -h2047 $(top_srcdir)/images/snake.png | $(WINE) ./img2sixel > /dev/null
$(WINE) ./img2sixel -w204 -h204 $(top_srcdir)/images/snake.png | $(WINE) ./img2sixel > /dev/null

@echo '[test5] DCS arguments handling'
seq 0 10 | while read i; do \
Expand Down
6 changes: 3 additions & 3 deletions converters/Makefile.in
Expand Up @@ -1070,10 +1070,10 @@ test_impl:
@WANT_IMG2SIXEL_TRUE@ @echo '[test4] conversion options'
@WANT_IMG2SIXEL_TRUE@ $(WINE) ./img2sixel $(top_srcdir)/images/snake.jpg -datkinson -flum -saverage | $(WINE) ./img2sixel | tee snake.sixel
@WANT_IMG2SIXEL_TRUE@ $(WINE) ./img2sixel -w50% -h150% -dfs -Bblue -thls -shistogram < $(top_srcdir)/images/snake.jpg | tee snake2.sixel
@WANT_IMG2SIXEL_TRUE@ $(WINE) ./img2sixel -w2100 -h2100 -djajuni -bxterm256 -o snake3.sixel < $(top_srcdir)/images/snake.jpg
@WANT_IMG2SIXEL_TRUE@ $(WINE) ./img2sixel -w210 -h210 -djajuni -bxterm256 -o snake3.sixel < $(top_srcdir)/images/snake.jpg
@WANT_IMG2SIXEL_TRUE@ $(WINE) ./img2sixel -w105% -h100 -B\#000000000 -rnearest < $(top_srcdir)/images/snake.gif
@WANT_IMG2SIXEL_TRUE@ $(WINE) ./img2sixel -7 -sauto -w100 -rgaussian -qauto -dburkes -tauto $(top_srcdir)/images/snake.tga
@WANT_IMG2SIXEL_TRUE@ $(WINE) ./img2sixel -p300 -8 -scenter -Brgb:0/f/A -h100 -qfull -rhanning -dstucki -thls $(top_srcdir)/images/snake.tiff
@WANT_IMG2SIXEL_TRUE@ $(WINE) ./img2sixel -p200 -8 -scenter -Brgb:0/f/A -h100 -qfull -rhanning -dstucki -thls $(top_srcdir)/images/snake.tiff
@WANT_IMG2SIXEL_TRUE@ $(WINE) ./img2sixel -8 -qauto -thls -e $(top_srcdir)/images/snake.pgm
@WANT_IMG2SIXEL_TRUE@ $(WINE) ./img2sixel -8 -m $(top_srcdir)/images/map8-palette.png -Esize $(top_srcdir)/images/snake.ppm
@WANT_IMG2SIXEL_TRUE@ $(WINE) ./img2sixel -7 -m $(top_srcdir)/images/map16-palette.png -Efast $(top_srcdir)/images/snake.jpg
Expand Down Expand Up @@ -1115,7 +1115,7 @@ test_impl:
@WANT_IMG2SIXEL_TRUE@ $(WINE) ./img2sixel -p 1 -h100 -n1 $(top_srcdir)/images/snake.jpg && printf '\033[*1z'
@WANT_IMG2SIXEL_TRUE@ $(WINE) ./img2sixel -e -h140 -rlanczos4 -P $(top_srcdir)/images/snake.jpg
@WANT_IMG2SIXEL_TRUE@ $(WINE) ./img2sixel -e -i -P $(top_srcdir)/images/snake.jpg > /dev/null
@WANT_IMG2SIXEL_TRUE@ $(WINE) ./img2sixel -w2047 -h2047 $(top_srcdir)/images/snake.png | $(WINE) ./img2sixel > /dev/null
@WANT_IMG2SIXEL_TRUE@ $(WINE) ./img2sixel -w204 -h204 $(top_srcdir)/images/snake.png | $(WINE) ./img2sixel > /dev/null

@WANT_IMG2SIXEL_TRUE@ @echo '[test5] DCS arguments handling'
@WANT_IMG2SIXEL_TRUE@ seq 0 10 | while read i; do \
Expand Down
2 changes: 1 addition & 1 deletion src/dither.c
Expand Up @@ -825,7 +825,7 @@ test1(void)
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
dither = sixel_dither_create(0);
dither = sixel_dither_create(2);
#if HAVE_DIAGNOSTIC_DEPRECATED_DECLARATIONS
# pragma GCC diagnostic pop
#endif
Expand Down
19 changes: 7 additions & 12 deletions src/fromgif.c
Expand Up @@ -181,7 +181,7 @@ gif_init_frame(
int ncolors;

frame->delay = pg->delay;
ncolors = 2 << (pg->flags & 7);
ncolors = 2 << (((pg->lflags & 0x80) ? pg->lflags : pg->flags) & 7);
if (frame->palette == NULL) {
frame->palette = (unsigned char *)sixel_allocator_malloc(frame->allocator, (size_t)(ncolors * 3));
} else if (frame->ncolors < ncolors) {
Expand Down Expand Up @@ -275,7 +275,7 @@ gif_out_code(
return;
}

g->out[g->cur_x + g->cur_y * g->line_size] = g->codes[code].suffix;
g->out[g->cur_x + g->cur_y * g->max_x] = g->codes[code].suffix;
if (g->cur_x >= g->actual_width) {
g->actual_width = g->cur_x + 1;
}
Expand Down Expand Up @@ -307,7 +307,6 @@ gif_process_raster(
SIXELSTATUS status = SIXEL_FALSE;
unsigned char lzw_cs;
signed int len, code;
unsigned int first;
signed int codesize, codemask, avail, oldcode, bits, valid_bits, clear;
gif_lzw *p;

Expand All @@ -321,7 +320,6 @@ gif_process_raster(
}

clear = 1 << lzw_cs;
first = 1;
codesize = lzw_cs + 1;
codemask = (1 << codesize) - 1;
bits = 0;
Expand Down Expand Up @@ -358,20 +356,13 @@ gif_process_raster(
codemask = (1 << codesize) - 1;
avail = clear + 2;
oldcode = -1;
first = 0;
} else if (code == clear + 1) { /* end of stream code */
s->img_buffer += len;
while ((len = gif_get8(s)) > 0) {
s->img_buffer += len;
}
return SIXEL_OK;
} else if (code <= avail) {
if (first) {
sixel_helper_set_additional_message(
"corrupt GIF (reason: no clear code).");
status = SIXEL_RUNTIME_ERROR;
goto end;
}
if (oldcode >= 0) {
if (avail < (1 << gif_lzw_max_code_size)) {
p = &g->codes[avail++];
Expand Down Expand Up @@ -434,7 +425,7 @@ gif_load_next(
y = gif_get16le(s); /* Image Top Position (2 bytes) */
w = gif_get16le(s); /* Image Width (2 bytes) */
h = gif_get16le(s); /* Image Height (2 bytes) */
if (((x + w) > (g->w)) || ((y + h) > (g->h))) {
if (x >= g->w || y >= g->h || x + w > g->w || y + h > g->h) {
sixel_helper_set_additional_message(
"corrupt GIF (reason: bad Image Separator).");
status = SIXEL_RUNTIME_ERROR;
Expand Down Expand Up @@ -514,6 +505,10 @@ gif_load_next(
g->delay = gif_get16le(s); /* delay */
g->transparent = gif_get8(s);
} else {
if (s->img_buffer + len > s->img_buffer_end) {
status = SIXEL_RUNTIME_ERROR;
goto end;
}
s->img_buffer += len;
break;
}
Expand Down
17 changes: 12 additions & 5 deletions src/fromsixel.c
Expand Up @@ -969,31 +969,33 @@ sixel_decode_raw(
image_buffer_t image;
int n;

image.data = NULL;

if (allocator) {
sixel_allocator_ref(allocator);
} else {
status = sixel_allocator_new(&allocator, NULL, NULL, NULL, NULL);
if (SIXEL_FAILED(status)) {
allocator = NULL;
goto end;
goto error;
}
}

/* parser context initialization */
status = parser_context_init(&context);
if (SIXEL_FAILED(status)) {
goto end;
goto error;
}

/* buffer initialization */
status = image_buffer_init(&image, 1, 1, context.bgindex, allocator);
if (SIXEL_FAILED(status)) {
goto end;
goto error;
}

status = sixel_decode_raw_impl(p, len, &image, &context, allocator);
if (SIXEL_FAILED(status)) {
goto end;
goto error;
}

*ncolors = image.ncolors + 1;
Expand All @@ -1008,7 +1010,7 @@ sixel_decode_raw(
sixel_helper_set_additional_message(
"sixel_deocde_raw: sixel_allocator_malloc() failed.");
status = SIXEL_BAD_ALLOCATION;
goto end;
goto error;
}
for (n = 0; n < *ncolors; ++n) {
(*palette)[n * 3 + 0] = image.palette[n] >> 16 & 0xff;
Expand All @@ -1021,6 +1023,11 @@ sixel_decode_raw(
*pixels = image.data;

status = SIXEL_OK;
goto end;

error:
free(image.data);
image.data = NULL;

end:
sixel_allocator_unref(allocator);
Expand Down
15 changes: 12 additions & 3 deletions src/stb_image.h
Expand Up @@ -5844,19 +5844,28 @@ static void *stbi__psd_load(stbi__context *s, int *x, int *y, int *comp, int req
if (ri->bits_per_channel == 16) { // output bpc
stbi__uint16 *q = ((stbi__uint16 *) out) + channel;
for (i = 0; i < pixelCount; i++, q += 4) {
if (stbi__at_eof(s)) return stbi__errpuc("bad file","PSD file too short");
if (stbi__at_eof(s)) {
STBI_FREE(out);
return stbi__errpuc("bad file","PSD file too short");
}
*q = (stbi__uint16) stbi__get16be(s);
}
} else {
stbi_uc *p = out+channel;
if (bitdepth == 16) { // input bpc
for (i = 0; i < pixelCount; i++, p += 4) {
if (stbi__at_eof(s)) return stbi__errpuc("bad file","PSD file too short");
if (stbi__at_eof(s)) {
STBI_FREE(out);
return stbi__errpuc("bad file","PSD file too short");
}
*p = (stbi_uc) (stbi__get16be(s) >> 8);
}
} else {
for (i = 0; i < pixelCount; i++, p += 4) {
if (stbi__at_eof(s)) return stbi__errpuc("bad file","PSD file too short");
if (stbi__at_eof(s)) {
STBI_FREE(out);
return stbi__errpuc("bad file","PSD file too short");
}
*p = stbi__get8(s);
}
}
Expand Down

0 comments on commit 020083b

Please sign in to comment.