Avoid double memory freeing leading to segmentation fault in the hameg-hmo driver when an SCPI command fails to get a string due conditions such as a timeout or an invalid command.
# sr: scpi: Timed out waiting for SCPI response. # double free or corruption (!prev) Signed-off-by: Guido Trentalancia <gu...@trentalancia.com> --- src/hardware/hameg-hmo/protocol.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff -pru libsigrok-git-orig/src/hardware/hameg-hmo/protocol.c libsigrok-git-hameg-hmo-avoid-double-free/src/hardware/hameg-hmo/protocol.c --- libsigrok-git-orig/src/hardware/hameg-hmo/protocol.c 2018-11-15 17:16:49.626199054 +0100 +++ libsigrok-git-hameg-hmo-avoid-double-free/src/hardware/hameg-hmo/protocol.c 2018-11-15 19:35:27.327485932 +0100 @@ -439,10 +439,8 @@ static int scope_state_get_array_option( char *tmp; int idx; - if (sr_scpi_get_string(scpi, command, &tmp) != SR_OK) { - g_free(tmp); + if (sr_scpi_get_string(scpi, command, &tmp) != SR_OK) return SR_ERR; - } if ((idx = std_str_idx_s(tmp, *array, n)) < 0) { g_free(tmp); _______________________________________________ sigrok-devel mailing list sigrok-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sigrok-devel