Added fix for segfault bug

Resolves: rhbz#1989084
This commit is contained in:
Richard Lescak 2021-09-16 11:45:14 +02:00
parent bcae1c34e3
commit f044d71dd8
2 changed files with 51 additions and 2 deletions

View File

@ -0,0 +1,46 @@
diff --git a/devices/vector/gdevtxtw.c b/devices/vector/gdevtxtw.c
index c6b95ed5b..f103d598b 100644
--- a/devices/vector/gdevtxtw.c
+++ b/devices/vector/gdevtxtw.c
@@ -1982,16 +1982,26 @@ textw_text_release(gs_text_enum_t *pte, client_name_t cname)
gx_device_txtwrite_t *const tdev = (gx_device_txtwrite_t *) pte->dev;
/* Free the working buffer where the Unicode was assembled from the enumerated text */
- if (penum->TextBuffer)
+ if (penum->TextBuffer) {
gs_free(tdev->memory, penum->TextBuffer, 1, penum->TextBufferIndex, "txtwrite free temporary text buffer");
- if (penum->Widths)
+ penum->TextBuffer = NULL;
+ }
+ if (penum->Widths) {
gs_free(tdev->memory, penum->Widths, sizeof(float), pte->text.size, "txtwrite free temporary widths array");
- if (penum->Advs)
+ penum->Widths = NULL;
+ }
+ if (penum->Advs) {
gs_free(tdev->memory, penum->Advs, 1, penum->TextBufferIndex, "txtwrite free temporary text buffer");
- if (penum->GlyphWidths)
+ penum->Advs = NULL;
+ }
+ if (penum->GlyphWidths) {
gs_free(tdev->memory, penum->GlyphWidths, 1, penum->TextBufferIndex, "txtwrite free temporary text buffer");
- if (penum->SpanDeltaX)
+ penum->GlyphWidths = NULL;
+ }
+ if (penum->SpanDeltaX) {
gs_free(tdev->memory, penum->SpanDeltaX, 1, penum->TextBufferIndex, "txtwrite free temporary text buffer");
+ penum->SpanDeltaX = NULL;
+ }
/* If this is copied away when we complete the text enumeration succesfully, then
* we set the pointer to NULL, if we get here with it non-NULL , then there was
* an error.
@@ -2008,6 +2018,7 @@ textw_text_release(gs_text_enum_t *pte, client_name_t cname)
if (penum->text_state->FontName)
gs_free(tdev->memory, penum->text_state->FontName, 1, penum->TextBufferIndex, "txtwrite free temporary font name copy");
gs_free(tdev->memory, penum->text_state, 1, sizeof(penum->text_state), "txtwrite free text state");
+ penum->text_state = NULL;
}
}
--
2.17.1

View File

@ -42,7 +42,7 @@
Name: ghostscript
Summary: Interpreter for PostScript language & PDF
Version: 9.54.0
Release: 2%{?dist}
Release: 3%{?dist}
License: AGPLv3+
@ -100,10 +100,10 @@ BuildRequires: make
# Upstream patches -- official upstream patches released by upstream since the
# ---------------- last rebase that are necessary for any reason:
#Patch000: example000.patch
Patch001: ghostscript-9.54.0-gdevtxtw-null-also-pointers.patch
# Downstream patches -- these should be always included when doing rebase:
# ------------------
# Downstream patches for RHEL -- patches that we keep only in RHEL for various
# --------------------------- reasons, but are not enabled in Fedora:
%if %{defined rhel} || %{defined centos}
@ -434,6 +434,9 @@ done
# =============================================================================
%changelog
* Thu Sep 16 2021 Richard Lescak <rlescak@redhat.com> - 9.54.0-3
- Added fix for segfault bug (#1989084)
* Mon Aug 09 2021 Mohan Boddu <mboddu@redhat.com> - 9.54.0-2
- Rebuilt for IMA sigs, glibc 2.34, aarch64 flags
Related: rhbz#1991688