mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
OSTCTools - Improve error management (II)
Have just found a .dive file in H&W forum which is not correctly parsed by libdivecomputer due (I think) to a bug in OSTC3 FW 1.77 (corrected). If libdc fails to parse a file (whatever is the reason) and the header hasn't been parsed, strcmp(ptr->key, "Serial") will segfault, so avoid comparison if there is no ostcdive->dc.extra_data but set the serial data as we know it from ostctools. Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
2ace3195f4
commit
521183dc73
1 changed files with 9 additions and 6 deletions
15
ostctools.c
15
ostctools.c
|
@ -174,13 +174,16 @@ void ostctools_import(const char *file, struct dive_table *divetable)
|
||||||
ostcdive->dc.serial = copy_string(tmp);
|
ostcdive->dc.serial = copy_string(tmp);
|
||||||
free(tmp);
|
free(tmp);
|
||||||
|
|
||||||
ptr = ostcdive->dc.extra_data;
|
if (ostcdive->dc.extra_data) {
|
||||||
while (strcmp(ptr->key, "Serial"))
|
ptr = ostcdive->dc.extra_data;
|
||||||
ptr = ptr->next;
|
while (strcmp(ptr->key, "Serial"))
|
||||||
if (!strcmp(ptr->value, "0")) {
|
ptr = ptr->next;
|
||||||
|
if (!strcmp(ptr->value, "0")) {
|
||||||
|
add_extra_data(&ostcdive->dc, "Serial", ostcdive->dc.serial);
|
||||||
|
*ptr = *(ptr)->next;
|
||||||
|
}
|
||||||
|
} else
|
||||||
add_extra_data(&ostcdive->dc, "Serial", ostcdive->dc.serial);
|
add_extra_data(&ostcdive->dc, "Serial", ostcdive->dc.serial);
|
||||||
*ptr = *(ptr)->next;
|
|
||||||
}
|
|
||||||
|
|
||||||
record_dive_to_table(ostcdive, divetable);
|
record_dive_to_table(ostcdive, divetable);
|
||||||
mark_divelist_changed(true);
|
mark_divelist_changed(true);
|
||||||
|
|
Loading…
Add table
Reference in a new issue