Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[worker] Use copy of target mode during transition. JB#43781
The common_map_mode_to_hardware() function can return the same
string that it was given as an argument. In the context of
worker_execute() function this can lead to using string pointer
that can get invalidated after releasing mutex.

Allocate copy of target mode before releasing mutex and use it
in the subsequent operations.

Signed-off-by: Simo Piiroinen <simo.piiroinen@jollamobile.com>
  • Loading branch information
spiiroin committed Nov 13, 2018
1 parent ccd8d21 commit 29d2f61
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/usb_moded-worker.c
Expand Up @@ -468,14 +468,17 @@ worker_execute(void)
log_debug("activate = %s", activate);

bool changed = g_strcmp0(activated, activate) != 0;
gchar *mode = g_strdup(activate);

WORKER_LOCKED_LEAVE;

if( changed )
worker_switch_to_mode(activate);
worker_switch_to_mode(mode);
else
worker_notify();

g_free(mode);

return;
}

Expand Down

0 comments on commit 29d2f61

Please sign in to comment.