Skip to content

Commit c0427dc

Browse files
author
murrell
committed
fix for PR#18784
git-svn-id: https://svn.r-project.org/R/trunk@87393 00db46b3-68df-0310-9c12-caf00c1e9a41
1 parent e56be51 commit c0427dc

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

doc/NEWS.Rd

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,11 @@
399399
\item \code{cbind()} could segfault with \code{NULL} inputs.
400400
(Seen when \R was built with \command{gcc14}, LTO and C99 inlining
401401
semantics.)
402+
403+
\item Fix segfault on \code{quartz()} from \code{grid.glyph()}
404+
call with \code{glyphInfo()} that describes non-existent font
405+
(\PR{18784}). Thanks to \I{Tomek Gieorgijewski}.
406+
402407
}
403408
}
404409
}

src/library/grDevices/src/devQuartz.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3024,13 +3024,12 @@ void RQuartz_glyph(int n, int *glyphs, double *x, double *y,
30243024
CFArrayRef cfFontDescriptors =
30253025
CTFontManagerCreateFontDescriptorsFromURL(cfFontURL);
30263026
CFRelease(cfFontURL);
3027-
int n_fonts = CFArrayGetCount(cfFontDescriptors);
3028-
if (n_fonts > 0) {
3027+
if (cfFontDescriptors) {
30293028
/* NOTE: that the font needs an inversion (in y) matrix
30303029
because the device has an inversion in user space
30313030
(for bitmap devices anyway) */
30323031
CGAffineTransform trans = CGAffineTransformMakeScale(1.0, -1.0);
3033-
if (rot != 0.0) trans = CGAffineTransformRotate(trans, rot/180.*M_PI);
3032+
if (rot != 0.0) trans = CGAffineTransformRotate(trans, rot/180.*M_PI);
30343033
CTFontRef ctFont =
30353034
CTFontCreateWithFontDescriptor((CTFontDescriptorRef) CFArrayGetValueAtIndex(cfFontDescriptors, 0), size, &trans);
30363035

@@ -3049,10 +3048,10 @@ void RQuartz_glyph(int n, int *glyphs, double *x, double *y,
30493048
}
30503049
CGColorRelease(fillColorRef);
30513050
CFRelease(ctFont);
3051+
CFRelease(cfFontDescriptors);
30523052
} else {
30533053
warning(_("Failed to load font"));
30543054
}
3055-
CFRelease(cfFontDescriptors);
30563055

30573056
QuartzEnd(grouping, layer, ctx, savedCTX, xd);
30583057
}

0 commit comments

Comments
 (0)