diff options
author | Uwe Hermann <uwe@hermann-uwe.de> | 2019-11-23 17:45:23 +0100 |
---|---|---|
committer | Uwe Hermann <uwe@hermann-uwe.de> | 2019-11-23 18:13:04 +0100 |
commit | b92543610e86daf57b0f042a899c9897d8234fa0 (patch) | |
tree | e106a6039b8995a4f3b567c258ed56fe32608c0c /instance.c | |
parent | 733047eda1c19e34fc55cdd7724999974f56176e (diff) | |
download | libsigrokdecode-b92543610e86daf57b0f042a899c9897d8234fa0.tar.gz libsigrokdecode-b92543610e86daf57b0f042a899c9897d8234fa0.zip |
Fix three -fsanitize=undefined issues.
instance.c:62:2: runtime error: null pointer passed as argument 1, which is declared to never be null
instance.c:858:45: runtime error: shift exponent -1 is negative
instance.c:836:45: runtime error: shift exponent -1 is negative
Diffstat (limited to 'instance.c')
-rw-r--r-- | instance.c | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -59,7 +59,8 @@ static void oldpins_array_seed(struct srd_decoder_inst *di) count = di->dec_num_channels; arr = g_array_sized_new(FALSE, TRUE, sizeof(uint8_t), count); g_array_set_size(arr, count); - memset(arr->data, SRD_INITIAL_PIN_SAME_AS_SAMPLE0, count); + if (arr->data) + memset(arr->data, SRD_INITIAL_PIN_SAME_AS_SAMPLE0, count); di->old_pins_array = arr; } @@ -831,6 +832,8 @@ static void update_old_pins_array(struct srd_decoder_inst *di, oldpins_array_seed(di); for (i = 0; i < di->dec_num_channels; i++) { + if (di->dec_channelmap[i] == -1) + continue; /* Ignore unused optional channels. */ byte_offset = di->dec_channelmap[i] / 8; bit_offset = di->dec_channelmap[i] % 8; sample = *(sample_pos + byte_offset) & (1 << bit_offset) ? 1 : 0; @@ -853,6 +856,8 @@ static void update_old_pins_array_initial_pins(struct srd_decoder_inst *di) for (i = 0; i < di->dec_num_channels; i++) { if (di->old_pins_array->data[i] != SRD_INITIAL_PIN_SAME_AS_SAMPLE0) continue; + if (di->dec_channelmap[i] == -1) + continue; /* Ignore unused optional channels. */ byte_offset = di->dec_channelmap[i] / 8; bit_offset = di->dec_channelmap[i] % 8; sample = *(sample_pos + byte_offset) & (1 << bit_offset) ? 1 : 0; |