core/csv-import: don't do pointer math after realloc

try_to_xslt_open_csv() re-allocates the memory passed in (not really great as
far as design goes, maybe something that should be reimplemented). Doing
pointer arithmatic with the returned base pointer results in garbage, unless
one gets super lucky and the realloc manages to not move the memory.

It's a wonder this ever worked.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2021-07-21 12:44:53 -07:00
parent 846e1ba53e
commit c90352008b

View file

@ -245,6 +245,7 @@ static int parse_dan_format(const char *filename, struct xml_params *params, str
return -1;
}
mem_csv.size = ptr - (char*)mem_csv.buffer;
end_ptr += ptr - (char *)mem_csv.buffer;
iter = parse_dan_new_line(ptr + 1, NL);
if (iter && strncmp(iter, "ZDT", 3) == 0) {
@ -268,7 +269,7 @@ static int parse_dan_format(const char *filename, struct xml_params *params, str
return -1;
ret |= parse_xml_buffer(filename, mem_csv.buffer, mem_csv.size, table, trips, sites, devices, filter_presets, params);
end_ptr += ptr - (char *)mem_csv.buffer;
free(mem_csv.buffer);
}