From 887d3a1bbcf79c692923d98f8b584b32a50daebd Mon Sep 17 00:00:00 2001 From: Evan Miller Date: Sun, 18 Feb 2024 14:44:23 -0500 Subject: [PATCH] [SAV reader] force parse error if attempting to decrement zero --- src/spss/readstat_sav_read.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/spss/readstat_sav_read.c b/src/spss/readstat_sav_read.c index 460bf07..d36bab9 100644 --- a/src/spss/readstat_sav_read.c +++ b/src/spss/readstat_sav_read.c @@ -717,7 +717,11 @@ static readstat_error_t sav_process_row(unsigned char *buffer, size_t buffer_len } if (++offset == col_info->width) { if (++segment_offset < var_info->n_segments) { - if (raw_str_used > 0) raw_str_used--; + if (raw_str_used == 0) { + retval = READSTAT_ERROR_PARSE; + goto done; + } + raw_str_used--; } offset = 0; col++;