Author: cazfi Date: Tue Oct 4 20:01:40 2016 New Revision: 33992 URL: http://svn.gna.org/viewcvs/freeciv?rev=33992&view=rev Log: Check existence of a file before trying to run xml-parser on it.
See bug #23759 Modified: trunk/utility/registry.c Modified: trunk/utility/registry.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/utility/registry.c?rev=33992&r1=33991&r2=33992&view=diff ============================================================================== --- trunk/utility/registry.c (original) +++ trunk/utility/registry.c Tue Oct 4 20:01:40 2016 @@ -1,4 +1,4 @@ -/********************************************************************** +/*********************************************************************** Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -51,11 +51,15 @@ bool allow_duplicates) { #ifdef FREECIV_HAVE_XML_REGISTRY - xmlDoc *sec_doc; + struct stat buf; - sec_doc = xmlReadFile(filename, NULL, XML_PARSE_NOERROR); - if (sec_doc != NULL) { - return xmlfile_load(sec_doc, filename); + if (fc_stat(filename, &buf) == 0) { + xmlDoc *sec_doc; + + sec_doc = xmlReadFile(filename, NULL, XML_PARSE_NOERROR); + if (sec_doc != NULL) { + return xmlfile_load(sec_doc, filename); + } } #endif /* FREECIV_HAVE_XML_REGISTRY */ _______________________________________________ Freeciv-commits mailing list Freeciv-commits@gna.org https://mail.gna.org/listinfo/freeciv-commits