Skip to content

Commit a58dfdf

Browse files
Disallow ---version on module calls (#4097) (#4098)
The --version and --show-datadir could be given to modules, but the price we paid was a memory leak and a call to exit. Since the gmt driver can return those parameters, as can the API, we remove these offensive lines. Co-authored-by: Paul Wessel <[email protected]>
1 parent a1339ce commit a58dfdf

File tree

1 file changed

+0
-22
lines changed

1 file changed

+0
-22
lines changed

src/gmt_init.c

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1440,25 +1440,6 @@ GMT_LOCAL int gmtinit_parse_dash_option (struct GMT_CTRL *GMT, char *text) {
14401440
if (!text)
14411441
return (GMT_NOERROR);
14421442

1443-
/* print version and exit */
1444-
if (strcmp (text, "version") == 0) {
1445-
snprintf (message, GMT_LEN128, "%s\n", GMT_PACKAGE_VERSION_WITH_GIT_REVISION);
1446-
GMT->parent->print_func (stdout, message);
1447-
/* cannot call gmt_M_free_options() from here, so we are leaking on exit.
1448-
* struct GMTAPI_CTRL *G = GMT->parent;
1449-
* if (GMT_Destroy_Session (G))
1450-
* GMT_exit (GMT, GMT_PARSE_ERROR); */
1451-
GMT_exit (GMT, GMT_NOERROR);
1452-
}
1453-
1454-
/* print GMT folders and exit */
1455-
if (strcmp (text, "show-datadir") == 0) {
1456-
snprintf (message, GMT_LEN128, "%s\n", GMT->session.SHAREDIR);
1457-
GMT->parent->print_func (stdout, message);
1458-
/* leaking on exit same as above. */
1459-
GMT_exit (GMT, GMT_NOERROR);
1460-
}
1461-
14621443
if ((this_c = strchr (text, '='))) {
14631444
/* Got --PAR=VALUE */
14641445
this_c[0] = '\0'; /* Temporarily remove the '=' character */
@@ -16392,9 +16373,6 @@ struct GMT_CTRL *gmt_begin (struct GMTAPI_CTRL *API, const char *session, unsign
1639216373
* which is called at the start of all GMT modules. This basically
1639316374
* performs a save/restore operation so that when the GMT module
1639416375
* returns the GMT structure is restored to its original values.
16395-
*
16396-
* Note: We do not call GMT_exit here since API is not given and
16397-
* API->do_not_exit have not been modified by external API yet.
1639816376
*/
1639916377

1640016378
struct GMT_CTRL *GMT = NULL;

0 commit comments

Comments
 (0)