From: James Turner Date: Sat, 5 Oct 2013 22:23:13 +0000 (+0100) Subject: Check for DAV status parse failures. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=0bd82a43d31a25b89bb67df9408e2c805ad72dd9;p=simgear.git Check for DAV status parse failures. --- diff --git a/simgear/io/DAVMultiStatus.cxx b/simgear/io/DAVMultiStatus.cxx index 53b34b67..a805a214 100644 --- a/simgear/io/DAVMultiStatus.cxx +++ b/simgear/io/DAVMultiStatus.cxx @@ -183,7 +183,8 @@ class DAVMultiStatus::DAVMultiStatusPrivate { public: DAVMultiStatusPrivate() : - parserInited(false) + parserInited(false), + valid(false) { rootResource = NULL; } @@ -287,6 +288,7 @@ public: } bool parserInited; + bool valid; XML_Parser xmlParser; DAVResource* rootResource; @@ -366,13 +368,21 @@ void DAVMultiStatus::parseXML(const char* data, int size) XML_ParserFree(_d->xmlParser); _d->parserInited = false; + _d->valid = false; } } void DAVMultiStatus::finishParse() { if (_d->parserInited) { - XML_Parse(_d->xmlParser, NULL, 0, true); + if (!XML_Parse(_d->xmlParser, NULL, 0, true)) { + SG_LOG(SG_IO, SG_WARN, "DAV parse error:" << XML_ErrorString(XML_GetErrorCode(_d->xmlParser)) + << " at line:" << XML_GetCurrentLineNumber(_d->xmlParser) + << " column " << XML_GetCurrentColumnNumber(_d->xmlParser)); + _d->valid = false; + } else { + _d->valid = true; + } XML_ParserFree(_d->xmlParser); } @@ -384,4 +394,9 @@ DAVResource* DAVMultiStatus::resource() return _d->rootResource; } +bool DAVMultiStatus::isValid() const +{ + return _d->valid; +} + diff --git a/simgear/io/DAVMultiStatus.hxx b/simgear/io/DAVMultiStatus.hxx index 862bf9d0..d415e5ae 100644 --- a/simgear/io/DAVMultiStatus.hxx +++ b/simgear/io/DAVMultiStatus.hxx @@ -129,6 +129,8 @@ public: void finishParse(); + bool isValid() const; + DAVResource* resource(); class DAVMultiStatusPrivate; diff --git a/simgear/io/SVNRepository.cxx b/simgear/io/SVNRepository.cxx index 62173ff9..b74df28c 100644 --- a/simgear/io/SVNRepository.cxx +++ b/simgear/io/SVNRepository.cxx @@ -173,7 +173,11 @@ namespace { // anonmouse { if (responseCode() == 207) { _davStatus.finishParse(); - _repo->propFindComplete(this, (DAVCollection*) _davStatus.resource()); + if (_davStatus.isValid()) { + _repo->propFindComplete(this, (DAVCollection*) _davStatus.resource()); + } else { + _repo->propFindFailed(this, SVNRepository::SVN_ERROR_SOCKET); + } } }