From 250cf666d321b03b3456ace94fdb5647d796fa92 Mon Sep 17 00:00:00 2001 From: niukuo Date: Mon, 29 Aug 2016 21:38:06 +0800 Subject: [PATCH] fix wrong length in remote schema Change-Id: Ia96ddf5746f1c18968e9e086f17fe4a24b8480d7 --- include/rapidjson/schema.h | 2 +- test/unittest/schematest.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/rapidjson/schema.h b/include/rapidjson/schema.h index b182aa27f..8497d3031 100644 --- a/include/rapidjson/schema.h +++ b/include/rapidjson/schema.h @@ -1473,7 +1473,7 @@ class GenericSchemaDocument { if (i > 0) { // Remote reference, resolve immediately if (remoteProvider_) { - if (const GenericSchemaDocument* remoteDocument = remoteProvider_->GetRemoteDocument(s, i - 1)) { + if (const GenericSchemaDocument* remoteDocument = remoteProvider_->GetRemoteDocument(s, i)) { PointerType pointer(&s[i], len - i, allocator_); if (pointer.IsValid()) { if (const SchemaType* sc = remoteDocument->GetSchema(pointer)) { diff --git a/test/unittest/schematest.cpp b/test/unittest/schematest.cpp index d75b1e593..6a8b685f4 100644 --- a/test/unittest/schematest.cpp +++ b/test/unittest/schematest.cpp @@ -1101,7 +1101,7 @@ class RemoteSchemaDocumentProvider : public IGenericRemoteSchemaDocumentProvider }; for (size_t i = 0; i < kCount; i++) - if (strncmp(uri, uris[i], length) == 0) + if (strncmp(uri, uris[i], length) == 0 && strlen(uris[i]) == length) return sd_[i]; return 0; }