summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorYuhong Zhang <34732434+YuhongZhang98@users.noreply.github.com>2023-01-05 14:55:42 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2023-01-09 17:29:01 +0000
commitef0e913ce74cc8869b7630aa5fc0743c5f1f447c (patch)
tree5292362b3ccd8db0be23a151cfc064028c83a504 /src
parentd90c776681c904ded016d62108c17fd3e605f6ae (diff)
downloadmongo-ef0e913ce74cc8869b7630aa5fc0743c5f1f447c.tar.gz
SERVER-72495 Return warnings about CodeWScope correctly in checkBSONConformance mode for validater6.2.0-rc5
(cherry picked from commit 58bf88893c373c84226671984b8dbfe21d630cb7)
Diffstat (limited to 'src')
-rw-r--r--src/mongo/bson/bson_validate.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/mongo/bson/bson_validate.cpp b/src/mongo/bson/bson_validate.cpp
index cb58767049e..7226a2c20f9 100644
--- a/src/mongo/bson/bson_validate.cpp
+++ b/src/mongo/bson/bson_validate.cpp
@@ -537,12 +537,14 @@ private:
while (size_t len = cursor.strlen()) {
uint8_t type = *cursor.ptr;
_currElem = cursor.ptr;
+ // In case _currElem is moved (for instance when the type is CodeWScope).
+ auto elemStart = cursor.ptr;
cursor.ptr += len + 1;
cursor.ptr = _validateElem(cursor, type);
// Check if the data is compliant to other BSON specifications if the element is
// structurally correct.
- _validator.checkNonConformantElem(_currElem, len + 1, type);
+ _validator.checkNonConformantElem(elemStart, len + 1, type);
if constexpr (precise) {
// See if the _id field was just validated. If so, set the global scope element.