From c937093ee9f89d6345dacaf0fe11353de7e880d7 Mon Sep 17 00:00:00 2001 From: Dengda98 Date: Fri, 16 May 2025 13:24:31 +0800 Subject: [PATCH 1/2] FIX: in *gmt_make_profiles* , fix annotation typos of +c and +d --- src/gmt_support.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gmt_support.c b/src/gmt_support.c index 76b19b49878..89fed090eaa 100644 --- a/src/gmt_support.c +++ b/src/gmt_support.c @@ -11348,8 +11348,8 @@ struct GMT_DATASET *gmt_make_profiles (struct GMT_CTRL *GMT, char option, char * /* step is given in either Cartesian units or, for geographic, in the prevailing unit (m, km) */ - if (strstr (args, "+c")) continuous = true; /* Want to add distances to the output */ - if (strstr (args, "+d")) get_distances = true; /* Want to join abutting profiles */ + if (strstr (args, "+c")) continuous = true; /* Want to join abutting profiles */ + if (strstr (args, "+d")) get_distances = true; /* Want to add distances to the output */ if (strstr (args, "+g")) gridline_units = true; /* Want degree longitudes or latitudes along a gridline */ if (strstr (args, "+p")) parallel = true; /* Want to sample along a parallel */ if (strstr (args, "+x")) GMT->current.map.loxodrome = true; /* Want to sample along a rhumbline */ From e672197dde7733508e48bead02c9cf927850ff50 Mon Sep 17 00:00:00 2001 From: Dengda98 Date: Fri, 16 May 2025 13:25:24 +0800 Subject: [PATCH 2/2] FIX: in *gmt_make_profiles* , add `get_distances` check to avoid segfault when using +c --- src/gmt_support.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/gmt_support.c b/src/gmt_support.c index 89fed090eaa..f635de96800 100644 --- a/src/gmt_support.c +++ b/src/gmt_support.c @@ -11543,8 +11543,10 @@ struct GMT_DATASET *gmt_make_profiles (struct GMT_CTRL *GMT, char option, char * else { /* Copy over but avoid repeating the joint */ gmt_M_memcpy (&(prev_S->data[GMT_X][start]), &(S->data[GMT_X][1]), add, double); gmt_M_memcpy (&(prev_S->data[GMT_Y][start]), &(S->data[GMT_Y][1]), add, double); - gmt_M_memcpy (&(prev_S->data[GMT_Z][start]), &(S->data[GMT_Z][1]), add, double); - for (rec = start; rec < prev_S->n_rows; rec++) prev_S->data[GMT_Z][rec] += prev_S->data[GMT_Z][start-1]; + if(get_distances){ + gmt_M_memcpy (&(prev_S->data[GMT_Z][start]), &(S->data[GMT_Z][1]), add, double); + for (rec = start; rec < prev_S->n_rows; rec++) prev_S->data[GMT_Z][rec] += prev_S->data[GMT_Z][start-1]; + } gmt_free_segment (GMT, &S); /* Done with this guy */ S = prev_S; }