Fix default filename handling errors

Linus Torvalds torvalds at linux-foundation.org
Sat Nov 10 06:32:06 PST 2012


The default filename handling is broken in two different ways:

 (a) if we start subsurface with a non-existing file, we warn about
the inability to read that file, and then we exit without setting the
default filename.

This is broken because it means that if the user (perhaps by mistake,
by pressing ^S) now saves the file, he will overwrite the default
filename, even though that was *not* the file we read, and *not* the
file that subsurface was started with.

So just set the default filename even for a failed file open.

The exact same logic is true of a failed parse of an XML file that we
successfully opened. We do *not* want to leave the old default
filename in place just because the XML parsing failed, and possibly
then overwriting some file that was never involved with that failure
in the first place. So just get rid of all the logic to push the
filename saving into the XML parsing layer, it has zero relevance at
that point.

 (b) if we do replace the default filename with a NULL file, we need
to set that even if we cannot do a strdup() on the NULL.

This fixes both errors.

Signed-off-by: Linus Torvalds <torvalds at linux-foundation.org>
---
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.diff
Type: application/octet-stream
Size: 3844 bytes
Desc: not available
URL: <http://lists.hohndel.org/pipermail/subsurface/attachments/20121110/cf8978be/attachment.obj>


More information about the subsurface mailing list