Skip to content

Commit

Permalink
If no input to greenspline then properly quit
Browse files Browse the repository at this point in the history
Instead we got a SEGV trail due to n == 0. Closes #8040.
  • Loading branch information
PaulWessel committed Nov 18, 2023
1 parent 3a3c000 commit 3aa9db8
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/greenspline.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 3aa9db8

Please sign in to comment.