Skip to content

Commit 408a2eb

Browse files
author
Rob Sanders
committed
Fix unneeded strdup/free of search pattern text
1 parent 5d14ef8 commit 408a2eb

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

libcli.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1889,9 +1889,9 @@ int cli_match_filter_init(struct cli_def *cli, int argc, char **argv, struct cli
18891889
if (!state) return CLI_ERROR;
18901890

18911891
if (!strcmp(cli->pipeline->current_stage->words[0], "include")) {
1892-
state->match.string = strdup(search_pattern);
1892+
state->match.string = search_pattern;
18931893
} else if (!strcmp(cli->pipeline->current_stage->words[0], "exclude")) {
1894-
state->match.string = strdup(search_pattern);
1894+
state->match.string = search_pattern;
18951895
state->flags = MATCH_INVERT;
18961896
#ifndef WIN32
18971897
} else {
@@ -1942,8 +1942,6 @@ int cli_match_filter(UNUSED(struct cli_def *cli), const char *string, void *data
19421942
if (!string) {
19431943
if (state->flags & MATCH_REGEX)
19441944
regfree(&state->match.re);
1945-
else
1946-
free(state->match.string);
19471945

19481946
free(state);
19491947
return CLI_OK;

0 commit comments

Comments
 (0)