From 6ec908afdcea6d85085fbb5e4adfe5067fe798dd Mon Sep 17 00:00:00 2001 From: Joaquim Date: Sun, 9 Nov 2025 23:25:19 +0000 Subject: [PATCH] Protect a call to fstat with a #ifdef _WIN64 See issue https://github.com/GenericMappingTools/gmt/issues/8825 Be cautious here as I don't really understand the why's. --- src/gmt_plot.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/gmt_plot.c b/src/gmt_plot.c index 66503470cb1..e6b3c70d3cc 100644 --- a/src/gmt_plot.c +++ b/src/gmt_plot.c @@ -10714,7 +10714,11 @@ struct GMT_POSTSCRIPT * gmtlib_read_ps (struct GMT_CTRL *GMT, void *source, unsi else if (source_type == GMT_IS_FDESC) { /* Open file descriptor given, just convert to file pointer */ struct stat buf; int *fd = source; - if (fstat (*fd, &buf)) { +#ifdef _WIN64 /* In lack of a clever solution, this is a hack for issue 8825 */ + if (_fstat64(*fd, &buf)) { +#else + if (fstat(*fd, &buf)) { +#endif GMT_Report (GMT->parent, GMT_MSG_ERROR, "Cannot determine size of PostScript file give by file descriptor %d\n", *fd); return (NULL); }