tool_paramhlp: refuse --proto remove all protocols
No binary (build failed)
—
(log yok)
| @@ -397,7 +397,7 @@ ParameterError proto2num(const char * const *val, char **ostr, const char *str) | |
| const char **protoset; | |
| struct dynbuf obuf; | |
| size_t proto; | |
| - | CURLcode result; |
| + | CURLcode result = CURLE_OK; |
| curlx_dyn_init(&obuf, MAX_PROTOSTRING); | |
| @@ -496,15 +496,19 @@ ParameterError proto2num(const char * const *val, char **ostr, const char *str) | |
| qsort((char *) protoset, protoset_index(protoset, NULL), sizeof(*protoset), | |
| struplocompare4sort); | |
| - | result = curlx_dyn_addn(&obuf, "", 0); |
| for(proto = 0; protoset[proto] && !result; proto++) | |
| - | result = curlx_dyn_addf(&obuf, "%s,", protoset[proto]); |
| + | result = curlx_dyn_addf(&obuf, "%s%s", curlx_dyn_len(&obuf) ? "," : "", |
| + | protoset[proto]); |
| free((char *) protoset); | |
| - | curlx_dyn_setlen(&obuf, curlx_dyn_len(&obuf) - 1); |
| + | if(result) |
| + | return PARAM_NO_MEM; |
| + | if(!curlx_dyn_len(&obuf)) { |
| + | curlx_dyn_free(&obuf); |
| + | return PARAM_BAD_USE; |
| + | } |
| free(*ostr); | |
| *ostr = curlx_dyn_ptr(&obuf); | |
| - | |
| - | return *ostr ? PARAM_OK : PARAM_NO_MEM; |
| + | return PARAM_OK; |
| } | |
| /** | |
| @@ -29,9 +29,9 @@ http | |
| # | |
| # Verify data after the test has been "shot" | |
| <verify> | |
| - | # 1 - Protocol "http" disabled |
| + | # 2 failed init, the --proto argument is not accepted |
| <errorcode> | |
| - | 1 |
| + | 2 |
| </errorcode> | |
| </verify> | |
| </testcase> | |