From 396d7dc76847b268cc696a969da67cc2159e56d2 Mon Sep 17 00:00:00 2001 From: Danny Smith Date: Tue, 8 Mar 2022 16:00:53 +1100 Subject: [PATCH] Fix off by one error in v,o indexing for string refs. Close #269 --- src/readstat_writer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/readstat_writer.c b/src/readstat_writer.c index bf20748b..82219f2b 100644 --- a/src/readstat_writer.c +++ b/src/readstat_writer.c @@ -604,8 +604,8 @@ readstat_error_t readstat_insert_string_ref(readstat_writer_t *writer, const rea return READSTAT_ERROR_STRING_REFS_NOT_SUPPORTED; if (ref && ref->first_o == -1 && ref->first_v == -1) { - ref->first_o = writer->current_row; - ref->first_v = variable->index; + ref->first_o = writer->current_row + 1; + ref->first_v = variable->index + 1; } return writer->callbacks.write_string_ref(&writer->row[variable->offset], variable, ref);