From 3aa9db8225f43b89e1f1f6ad4f8fdabd911f3822 Mon Sep 17 00:00:00 2001 From: Paul Wessel Date: Sat, 18 Nov 2023 12:00:37 +0100 Subject: [PATCH] If no input to greenspline then properly quit Instead we got a SEGV trail due to n == 0. Closes #8040. --- src/greenspline.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/greenspline.c b/src/greenspline.c index c068f984e2e..7277da68ad0 100644 --- a/src/greenspline.c +++ b/src/greenspline.c @@ -1836,6 +1836,13 @@ EXTERN_MSC int GMT_greenspline (void *V_API, int mode, void *args) { Return (API->error); } + if (n == 0) { /* Empty input file */ + for (p = 0; p < n; p++) gmt_M_free (GMT, X[p]); + gmt_M_free (GMT, X); gmt_M_free (GMT, obs); + GMT_Report (API, GMT_MSG_ERROR, "No data records found - aborting!\n"); + Return (GMT_RUNTIME_ERROR); + } + X = gmt_M_memory (GMT, X, n, double *); obs = gmt_M_memory (GMT, obs, n, double); nm = n;