summaryrefslogtreecommitdiffstats
path: root/parse-xml.c
diff options
context:
space:
mode:
authorGravatar Linus Torvalds <torvalds@linux-foundation.org>2012-11-10 15:32:06 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2012-11-10 16:02:05 +0100
commit3d8c1e50fcc2c7e2ab43e8d09bf00e0610d69eaa (patch)
tree964065f93a8c96031bb47058993890b4f42adfc8 /parse-xml.c
parent080bcc10fc5e1651bc31f2260ef85376a8356c0b (diff)
downloadsubsurface-3d8c1e50fcc2c7e2ab43e8d09bf00e0610d69eaa.tar.gz
Fix default filename handling errors
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@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'parse-xml.c')
-rw-r--r--parse-xml.c6
1 files changed, 1 insertions, 5 deletions
diff --git a/parse-xml.c b/parse-xml.c
index 272b82c0f..b4fc9e716 100644
--- a/parse-xml.c
+++ b/parse-xml.c
@@ -1485,8 +1485,7 @@ static void reset_all(void)
import_source = UNKNOWN;
}
-void parse_xml_buffer(const char *url, const char *buffer, int size, GError **error,
- gboolean possible_default_filename)
+void parse_xml_buffer(const char *url, const char *buffer, int size, GError **error)
{
xmlDoc *doc;
@@ -1502,9 +1501,6 @@ void parse_xml_buffer(const char *url, const char *buffer, int size, GError **er
}
return;
}
- /* remember, if necessary, that this is the filename to store to */
- if (possible_default_filename)
- set_filename(url, FALSE);
reset_all();
dive_start();
#ifdef XSLT