diff --git a/src/runtime/c/pgf/parser.cxx b/src/runtime/c/pgf/parser.cxx index 6751aec75..1cf30185d 100644 --- a/src/runtime/c/pgf/parser.cxx +++ b/src/runtime/c/pgf/parser.cxx @@ -1676,11 +1676,15 @@ bool PgfParser::change(size_t i, PgfText *change) allocated_size = new_allocated_size; } - const uint8_t *ptr1 = - (prev_state!=NULL) - ? (uint8_t *) &sentence->text[prev_state->start.byte_pos] - : NULL; - size_t pos = prev_state->start.pos; + size_t pos; + const uint8_t *ptr1; + if (prev_state!=NULL) { + ptr1 = (uint8_t *) &sentence->text[prev_state->start.byte_pos]; + pos = prev_state->start.pos; + } else { + ptr1 = (uint8_t *) sentence->text; + pos = 0; + } while (pos < update_new_pos) { pgf_utf8_decode(&ptr1); pos++; }