diff --git a/ChangeLog.adoc b/ChangeLog.adoc index 5b08feae6..9c9aae167 100644 --- a/ChangeLog.adoc +++ b/ChangeLog.adoc @@ -24,6 +24,7 @@ New features:: Bug fixes:: + * core: display an error with command `/history N` when N is not a valid integer * core: fix memory leak when config version is invalid or not supported * core: fix crash when "config_version" is present in a configuration file without a value * core: display an error on startup if environment variable "HOME" is not set diff --git a/src/core/wee-command.c b/src/core/wee-command.c index 00631cc6a..f0361db58 100644 --- a/src/core/wee-command.c +++ b/src/core/wee-command.c @@ -3386,6 +3386,7 @@ COMMAND_CALLBACK(history) { struct t_gui_history *ptr_history; int n, n_total, n_user, displayed; + char *error; /* make C compiler happy */ (void) pointer; @@ -3402,7 +3403,12 @@ COMMAND_CALLBACK(history) return WEECHAT_RC_OK; } else - n_user = atoi (argv[1]); + { + error = NULL; + n_user = (int)strtol (argv[1], &error, 10); + if (!error || error[0] || (n_user < 0)) + COMMAND_ERROR; + } } if (buffer->history)