On Sun, Jul 14, 2019 at 6:16 AM Steve <[email protected]> wrote:
>
> (gdb) where
> #0 0x0000000000708fcd in save_cylinder_info (dive=0xc34f240,
> b=0x7fffffffc2c0) at /home/steve/src/subsurface/core/save-xml.c:193
Interesting. It looks like you likely have an odd cylinder "use"
string that you load, resulting in cylinder->use being an invalid
value.
It might be some translation thing (but the use strings *shouldn't* be
translated, even if we have some bad QT_TRANSLATE_NOOP()) markers
there, but since you're first loading and then saving, maybe the old
load-file has some buggy tranbslated value.
We try to untranslate at load time, but that depends on the locale
being the same as the saving locale had been. Which it probably isn't
for you. Just based on the name/email I'm guessing Australia -
Adelaide? - and English. But at some point you had tested some
localization, and your old file thus had an illegible cylinder use
string.
Anyway, the save_cylinder_info() code doesn't check for invalid
cylinder use numbers, and can do bad things if they are garbage.
Maybe a patch like the attached?
Linus
core/dive.c | 2 +-
core/dive.h | 2 +-
core/save-xml.c | 8 ++++++--
3 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/core/dive.c b/core/dive.c
index 97d82821c..b53982066 100644
--- a/core/dive.c
+++ b/core/dive.c
@@ -23,7 +23,7 @@
* here */
struct dive displayed_dive;
-const char *cylinderuse_text[] = {
+const char *cylinderuse_text[NUM_GAS_USE] = {
QT_TRANSLATE_NOOP("gettextFromC", "OC-gas"), QT_TRANSLATE_NOOP("gettextFromC", "diluent"), QT_TRANSLATE_NOOP("gettextFromC", "oxygen"), QT_TRANSLATE_NOOP("gettextFromC", "not used")
};
diff --git a/core/dive.h b/core/dive.h
index e9bb926ae..ca42406d5 100644
--- a/core/dive.h
+++ b/core/dive.h
@@ -23,7 +23,7 @@ extern int last_xml_version;
enum divemode_t {OC, CCR, PSCR, FREEDIVE, NUM_DIVEMODE, UNDEF_COMP_TYPE}; // Flags (Open-circuit and Closed-circuit-rebreather) for setting dive computer type
-extern const char *cylinderuse_text[];
+extern const char *cylinderuse_text[NUM_GAS_USE];
extern const char *divemode_text_ui[];
extern const char *divemode_text[];
diff --git a/core/save-xml.c b/core/save-xml.c
index 0af114ba0..0cd81ee60 100644
--- a/core/save-xml.c
+++ b/core/save-xml.c
@@ -180,6 +180,7 @@ static void save_cylinder_info(struct membuffer *b, struct dive *dive)
cylinder_t *cylinder = dive->cylinder + i;
int volume = cylinder->type.size.mliter;
const char *description = cylinder->type.description;
+ int use = cylinder->cylinder_use;
put_format(b, " <cylinder");
if (volume)
@@ -189,8 +190,11 @@ static void save_cylinder_info(struct membuffer *b, struct dive *dive)
put_gasmix(b, cylinder->gasmix);
put_pressure(b, cylinder->start, " start='", " bar'");
put_pressure(b, cylinder->end, " end='", " bar'");
- if (cylinder->cylinder_use != OC_GAS)
- show_utf8(b, cylinderuse_text[cylinder->cylinder_use], " use='", "'", 1);
+ if (use > OC_GAS && use < NUM_GAS_USE) {
+ const char *use_string = cylinderuse_text[use];
+ if (use_string)
+ show_utf8(b, use_string, " use='", "'", 1);
+ }
if (cylinder->depth.mm != 0)
put_milli(b, " depth='", cylinder->depth.mm, " m'");
put_format(b, " />\n");
_______________________________________________
subsurface mailing list
[email protected]
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface