mirror of
https://github.com/mpv-player/mpv.git
synced 2025-12-22 10:57:08 +00:00
client: don't take ownership of result if it is not returned
This fixes memory leak that occured when NULL was passed as result.
This commit is contained in:
committed by
Kacper Michajłow
parent
1d71523407
commit
91b79d961a
@@ -1149,7 +1149,7 @@ int mpv_command(mpv_handle *ctx, const char **args)
|
||||
int mpv_command_node(mpv_handle *ctx, mpv_node *args, mpv_node *result)
|
||||
{
|
||||
struct mpv_node rn = {.format = MPV_FORMAT_NONE};
|
||||
int r = run_client_command(ctx, mp_input_parse_cmd_node(ctx->log, args), &rn);
|
||||
int r = run_client_command(ctx, mp_input_parse_cmd_node(ctx->log, args), result ? &rn : NULL);
|
||||
if (result && r >= 0)
|
||||
*result = rn;
|
||||
return r;
|
||||
@@ -1158,7 +1158,7 @@ int mpv_command_node(mpv_handle *ctx, mpv_node *args, mpv_node *result)
|
||||
int mpv_command_ret(mpv_handle *ctx, const char **args, mpv_node *result)
|
||||
{
|
||||
struct mpv_node rn = {.format = MPV_FORMAT_NONE};
|
||||
int r = run_client_command(ctx, mp_input_parse_cmd_strv(ctx->log, args), &rn);
|
||||
int r = run_client_command(ctx, mp_input_parse_cmd_strv(ctx->log, args), result ? &rn : NULL);
|
||||
if (result && r >= 0)
|
||||
*result = rn;
|
||||
return r;
|
||||
|
||||
Reference in New Issue
Block a user