summaryrefslogtreecommitdiff
path: root/src/mongo/bson/bsonelement.h
diff options
context:
space:
mode:
authorAdam Midvidy <amidvidy@gmail.com>2014-09-19 16:43:33 -0400
committerBenety Goh <benety@mongodb.com>2014-09-19 16:50:23 -0400
commit78c5f9dd5ac65eae251df3e87175a0af076d90d9 (patch)
treee305dcd559f6b8f8a1ed987e6938e5b8406fea19 /src/mongo/bson/bsonelement.h
parent63dd64abac9002e71348b7550234131cd01a87f5 (diff)
downloadmongo-78c5f9dd5ac65eae251df3e87175a0af076d90d9.tar.gz
SERVER-15210 SERVER-15211 remove OID undefined behavior and make it endian aware
Closes #784 Signed-off-by: Benety Goh <benety@mongodb.com>
Diffstat (limited to 'src/mongo/bson/bsonelement.h')
-rw-r--r--src/mongo/bson/bsonelement.h8
1 files changed, 2 insertions, 6 deletions
diff --git a/src/mongo/bson/bsonelement.h b/src/mongo/bson/bsonelement.h
index e2dad9f071d..5cbfadc434f 100644
--- a/src/mongo/bson/bsonelement.h
+++ b/src/mongo/bson/bsonelement.h
@@ -252,9 +252,7 @@ namespace mongo {
/** Retrieve the object ID stored in the object.
You must ensure the element is of type jstOID first. */
mongo::OID __oid() const {
- class OID oid;
- std::memcpy(&oid, value(), sizeof(oid));
- return oid;
+ return OID::from(value());
}
/** True if element is null. */
@@ -454,9 +452,7 @@ namespace mongo {
uassert( 10064 , "not a dbref" , type() == DBRef );
const char * start = value();
start += 4 + ConstDataView(start).readLE<int>();
- class OID result;
- std::memcpy(&result, start, sizeof(result));
- return result;
+ return mongo::OID::from(start);
}
/** this does not use fieldName in the comparison, just the value */