Skip to content

Commit

Permalink
plugins/cn0540: fix segmentation fault
Browse files Browse the repository at this point in the history
allocate enough space for channel labels with double digits and NULL
add NULL for channels with double digits

Signed-off-by: Cristina Suteu <cristina.suteu@analog.com>
  • Loading branch information
cristina-suteu committed Oct 3, 2023
1 parent d60dc51 commit 8ae9847
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion plugins/cn0540.c
Expand Up @@ -348,7 +348,7 @@ static void cn0540_get_channels()
{
gboolean direction = TRUE;
int idx = -1;
char label[9] = "voltage0";
char label[10] = "voltage0";

adc_ch = iio_device_find_channel(iio_adc, ADC_DEVICE_CH, FALSE);
dac_ch = iio_device_find_channel(iio_dac, DAC_DEVICE_CH, TRUE);
Expand Down Expand Up @@ -385,6 +385,7 @@ static void cn0540_get_channels()
if (label[7] == ':') {
label[7] = '1';
label[8] = '0';
label[9] = 0;
}
}
}
Expand Down

0 comments on commit 8ae9847

Please sign in to comment.