On 5/19/26 3:19 PM, Timothy Redaelli via dev wrote:
> When local_options are present but no command name follows,
> the early return leaked the previously allocated commands array.
> 
> Free commands before returning the error string.
> 
> Found by OpenScanHub Coverity (RESOURCE_LEAK).
> Signed-off-by: Timothy Redaelli <[email protected]>
> ---
>  lib/db-ctl-base.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/lib/db-ctl-base.c b/lib/db-ctl-base.c
> index bd3a21dd9..67ef0215e 100644
> --- a/lib/db-ctl-base.c
> +++ b/lib/db-ctl-base.c
> @@ -2480,6 +2480,7 @@ ctl_parse_commands(int argc, char *argv[], struct shash 
> *local_options,
>  
>                  n_commands++;
>              } else if (!shash_is_empty(local_options)) {
> +                free(commands);
>                  return xstrdup("missing command name (use --help for help)");

Hmm.  This doesn't look right.  The parse_command() consumes local_options,
so they are always empty if we ever tried to parse any command.  So, if we
are taking this branch, then it means that commands were never allocated.
Besides, if we have commands allocated, then we need to destroy them before
freeing the holding array.  Or am I missing something here?

Best regards, Ilya Maximets.
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to