mirror of https://github.com/MidnightCommander/mc
Fix trailing whitespace problem.
sscanf() returns EOF when it reaches the end of the string. Our code erroneously interprets this as if a number was read. The fix: we test for an explicit '1'. Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
b25af93874
commit
cc8fcdcfc0
|
@ -85,7 +85,7 @@ mc_search__hex_translate_to_regex (const GString * astr, mc_search_hex_parse_err
|
|||
int ptr;
|
||||
|
||||
/* cppcheck-suppress invalidscanf */
|
||||
if (sscanf (tmp_str + loop, "%x%n", &val, &ptr))
|
||||
if (sscanf (tmp_str + loop, "%x%n", &val, &ptr) == 1)
|
||||
{
|
||||
if (val > 255)
|
||||
error = MC_SEARCH_HEX_E_NUM_OUT_OF_RANGE;
|
||||
|
|
|
@ -56,8 +56,8 @@ static const struct test_hex_translate_to_regex_ds
|
|||
MC_SEARCH_HEX_E_OK
|
||||
},
|
||||
{
|
||||
/* Extra whitespace (but not trailing one) */
|
||||
" 12 34",
|
||||
/* Extra whitespace */
|
||||
" 12 34 ",
|
||||
"\\x12\\x34",
|
||||
MC_SEARCH_HEX_E_OK
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue