summaryrefslogtreecommitdiff
path: root/fxjs/cfxjs_engine.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2018-04-05 22:41:53 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-04-05 22:41:53 +0000
commit4862705090a7469115ae7e3c80143b6f8b6b527a (patch)
treea7894aa174e3621bfa15e4070e418ee2b1f01f31 /fxjs/cfxjs_engine.cpp
parent0c5928825d0bc0c397e90d2c4861feaf9bdc6d24 (diff)
downloadpdfium-4862705090a7469115ae7e3c80143b6f8b6b527a.tar.xz
Make Internal field usage in cfxjs_engine match README.doc
As it turns out, this doesn't cause any bugs with the FXJS/FXJSE interaction since the magic values will never be present in the other slot, but the code looks wrong wrt. the document. Also fix an assert in FXJSE that our objects have two slots, and null appropriately (just a defensive measure). Also assert that one of our casts is valid. Change-Id: I3146fe58350da5e9b76e711d81480565dabd587f Reviewed-on: https://pdfium-review.googlesource.com/29859 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'fxjs/cfxjs_engine.cpp')
-rw-r--r--fxjs/cfxjs_engine.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/fxjs/cfxjs_engine.cpp b/fxjs/cfxjs_engine.cpp
index 561a0a31f9..54aa28cf4b 100644
--- a/fxjs/cfxjs_engine.cpp
+++ b/fxjs/cfxjs_engine.cpp
@@ -93,20 +93,20 @@ class CFXJS_PerObjectData {
static void SetInObject(CFXJS_PerObjectData* pData,
v8::Local<v8::Object> pObj) {
if (pObj->InternalFieldCount() == 2) {
- pObj->SetAlignedPointerInInternalField(0, pData);
pObj->SetAlignedPointerInInternalField(
- 1, static_cast<void*>(kPerObjectDataTag));
+ 0, static_cast<void*>(kPerObjectDataTag));
+ pObj->SetAlignedPointerInInternalField(1, pData);
}
}
static CFXJS_PerObjectData* GetFromObject(v8::Local<v8::Object> pObj) {
if (pObj.IsEmpty() || pObj->InternalFieldCount() != 2 ||
- pObj->GetAlignedPointerFromInternalField(1) !=
+ pObj->GetAlignedPointerFromInternalField(0) !=
static_cast<void*>(kPerObjectDataTag)) {
return nullptr;
}
return static_cast<CFXJS_PerObjectData*>(
- pObj->GetAlignedPointerFromInternalField(0));
+ pObj->GetAlignedPointerFromInternalField(1));
}
const int m_ObjDefID;