1
0
mirror of https://github.com/moparisthebest/curl synced 2024-08-13 17:03:50 -04:00

--help: strdup the category

... since it is converted and the original pointer is freed on Windows
unicode handling.

Follow-up to aa8777f63f
Fixes #5977
Closes #5978
Reported-by: xwxbug on github
This commit is contained in:
Daniel Stenberg 2020-09-18 08:09:09 +02:00
parent 2df7414a73
commit 5bd63e0619
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2
3 changed files with 14 additions and 14 deletions

View File

@ -1777,7 +1777,11 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */
case 'h': /* h for help */
if(toggle) {
global->help_category = nextarg;
if(nextarg) {
global->help_category = strdup(nextarg);
if(!global->help_category)
return PARAM_NO_MEM;
}
return PARAM_HELP_REQUESTED;
}
/* we now actually support --no-help too! */

View File

@ -899,7 +899,7 @@ static void get_categories(void)
}
void tool_help(const char *category)
void tool_help(char *category)
{
puts("Usage: curl [options...] <url>");
/* If no category was provided */
@ -910,24 +910,20 @@ void tool_help(const char *category)
" or \"--help all\".";
print_category(CURLHELP_IMPORTANT);
puts(category_note);
return;
}
/* Lets print everything if "all" was provided */
if(curl_strequal(category, "all")) {
else if(curl_strequal(category, "all"))
/* Print everything except hidden */
print_category(~(CURLHELP_HIDDEN));
return;
}
/* Lets handle the string "category" differently to not print an errormsg */
if(curl_strequal(category, "category")) {
else if(curl_strequal(category, "category"))
get_categories();
return;
}
/* Otherwise print category and handle the case if the cat was not found */
if(get_category_content(category)) {
else if(get_category_content(category)) {
puts("Invalid category provided, here is a list of all categories:\n");
get_categories();
}
free(category);
}
static int

View File

@ -23,7 +23,7 @@
***************************************************************************/
#include "tool_setup.h"
void tool_help(const char *category);
void tool_help(char *category);
void tool_list_engines(void);
void tool_version_info(void);