parent
eeb16e021c
commit
d48ff88f5d
2 changed files with 6 additions and 106 deletions
|
@ -1,100 +0,0 @@
|
||||||
From 3dd0e308cbd2c24fde2fc9e9b707181252a2de95 Mon Sep 17 00:00:00 2001
|
|
||||||
From: "Christoph M. Becker" <cmbecker69@gmx.de>
|
|
||||||
Date: Tue, 5 May 2020 12:02:45 +0200
|
|
||||||
Subject: [PATCH] Fix #615: gdImageStringFT() fails for empty strings as of
|
|
||||||
libgd 2.3.0 (#633)
|
|
||||||
|
|
||||||
We change the return type of `textLayout()` to `ssize_t`, and signal
|
|
||||||
failure by returning `-1`, so that laying out an empty string is no
|
|
||||||
longer handled as failure. We make sure that no overflow occurs,
|
|
||||||
assuming that all `int` values can be fully represented as `ssize_t`.
|
|
||||||
---
|
|
||||||
src/gdft.c | 18 +++++++++---------
|
|
||||||
tests/gdimagestringft/.gitignore | 1 +
|
|
||||||
tests/gdimagestringft/CMakeLists.txt | 1 +
|
|
||||||
tests/gdimagestringft/Makemodule.am | 1 +
|
|
||||||
tests/gdimagestringft/bug00615.c | 25 +++++++++++++++++++++++++
|
|
||||||
5 files changed, 37 insertions(+), 9 deletions(-)
|
|
||||||
create mode 100644 tests/gdimagestringft/bug00615.c
|
|
||||||
|
|
||||||
diff --git a/src/gdft.c b/src/gdft.c
|
|
||||||
index b483b383..186eefff 100644
|
|
||||||
--- a/src/gdft.c
|
|
||||||
+++ b/src/gdft.c
|
|
||||||
@@ -441,7 +441,7 @@ typedef struct {
|
|
||||||
uint32_t cluster;
|
|
||||||
} glyphInfo;
|
|
||||||
|
|
||||||
-static size_t
|
|
||||||
+static ssize_t
|
|
||||||
textLayout(uint32_t *text, int len,
|
|
||||||
FT_Face face, gdFTStringExtraPtr strex,
|
|
||||||
glyphInfo **glyph_info)
|
|
||||||
@@ -459,19 +459,19 @@ textLayout(uint32_t *text, int len,
|
|
||||||
!raqm_set_par_direction (rq, RAQM_DIRECTION_DEFAULT) ||
|
|
||||||
!raqm_layout (rq)) {
|
|
||||||
raqm_destroy (rq);
|
|
||||||
- return 0;
|
|
||||||
+ return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
glyphs = raqm_get_glyphs (rq, &count);
|
|
||||||
if (!glyphs) {
|
|
||||||
raqm_destroy (rq);
|
|
||||||
- return 0;
|
|
||||||
+ return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
info = (glyphInfo*) gdMalloc (sizeof (glyphInfo) * count);
|
|
||||||
if (!info) {
|
|
||||||
raqm_destroy (rq);
|
|
||||||
- return 0;
|
|
||||||
+ return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < count; i++) {
|
|
||||||
@@ -489,7 +489,7 @@ textLayout(uint32_t *text, int len,
|
|
||||||
FT_Error err;
|
|
||||||
info = (glyphInfo*) gdMalloc (sizeof (glyphInfo) * len);
|
|
||||||
if (!info) {
|
|
||||||
- return 0;
|
|
||||||
+ return -1;
|
|
||||||
}
|
|
||||||
for (count = 0; count < len; count++) {
|
|
||||||
/* Convert character code to glyph index */
|
|
||||||
@@ -508,7 +508,7 @@ textLayout(uint32_t *text, int len,
|
|
||||||
err = FT_Load_Glyph (face, glyph_index, FT_LOAD_DEFAULT);
|
|
||||||
if (err) {
|
|
||||||
gdFree (info);
|
|
||||||
- return 0;
|
|
||||||
+ return -1;
|
|
||||||
}
|
|
||||||
info[count].index = glyph_index;
|
|
||||||
info[count].x_offset = 0;
|
|
||||||
@@ -527,7 +527,7 @@ textLayout(uint32_t *text, int len,
|
|
||||||
#endif
|
|
||||||
|
|
||||||
*glyph_info = info;
|
|
||||||
- return count;
|
|
||||||
+ return count <= SSIZE_MAX ? count : -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/********************************************************************/
|
|
||||||
@@ -1108,7 +1108,7 @@ BGD_DECLARE(char *) gdImageStringFTEx (gdImage * im, int *brect, int fg, const c
|
|
||||||
char *tmpstr = 0;
|
|
||||||
uint32_t *text;
|
|
||||||
glyphInfo *info = NULL;
|
|
||||||
- size_t count;
|
|
||||||
+ ssize_t count;
|
|
||||||
int render = (im && (im->trueColor || (fg <= 255 && fg >= -255)));
|
|
||||||
FT_BitmapGlyph bm;
|
|
||||||
/* 2.0.13: Bob Ostermann: don't force autohint, that's just for testing
|
|
||||||
@@ -1409,7 +1409,7 @@ BGD_DECLARE(char *) gdImageStringFTEx (gdImage * im, int *brect, int fg, const c
|
|
||||||
|
|
||||||
count = textLayout (text , i, face, strex, &info);
|
|
||||||
|
|
||||||
- if (!count) {
|
|
||||||
+ if (count < 0) {
|
|
||||||
gdFree (text);
|
|
||||||
gdFree (tmpstr);
|
|
||||||
gdCacheDelete (tc_cache);
|
|
|
@ -1,20 +1,20 @@
|
||||||
# Template file for 'gd'
|
# Template file for 'gd'
|
||||||
pkgname=gd
|
pkgname=gd
|
||||||
version=2.3.0
|
version=2.3.1
|
||||||
revision=2
|
revision=1
|
||||||
wrksrc="libgd-${version}"
|
wrksrc="libgd-${version}"
|
||||||
build_style=gnu-configure
|
build_style=gnu-configure
|
||||||
configure_args="--without-xpm"
|
configure_args="--without-xpm"
|
||||||
hostmakedepends="pkg-config"
|
hostmakedepends="pkg-config"
|
||||||
makedepends="libjpeg-turbo-devel libpng-devel libwebp-devel tiff-devel fontconfig-devel"
|
makedepends="libjpeg-turbo-devel libpng-devel libwebp-devel tiff-devel fontconfig-devel"
|
||||||
|
# There needs to be a font installed for fontconfig/basic test
|
||||||
|
checkdepends="liberation-fonts-ttf"
|
||||||
short_desc="Graphics library for the dynamic creation of images"
|
short_desc="Graphics library for the dynamic creation of images"
|
||||||
maintainer="Orphaned <orphan@voidlinux.org>"
|
maintainer="Orphaned <orphan@voidlinux.org>"
|
||||||
|
license="custom:BSD-like"
|
||||||
homepage="http://www.libgd.org/"
|
homepage="http://www.libgd.org/"
|
||||||
license="BSD"
|
|
||||||
distfiles="https://github.com/libgd/libgd/releases/download/gd-${version}/libgd-${version}.tar.xz"
|
distfiles="https://github.com/libgd/libgd/releases/download/gd-${version}/libgd-${version}.tar.xz"
|
||||||
checksum=ecd9155b9a417fb3f837f29e5966323796de247789163761dd72dbf83bfcac58
|
checksum=9767917d9f818faec4ddd763fe4a4ad9f6322c3d25da290ab2ea3e2ce4b52a7b
|
||||||
|
|
||||||
patch_args="-Np1"
|
|
||||||
|
|
||||||
post_install() {
|
post_install() {
|
||||||
vlicense COPYING
|
vlicense COPYING
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue