thread_checker_ = std::make_unique<base::ThreadChecker>();
}
-VarTracker::~VarTracker() {}
+VarTracker::~VarTracker() {
+#if defined(TIZEN_PEPPER_EXTENSIONS)
+ // If VarDictionary is nested in live_vars_ and live_vars_ is being destroyed,
+ // then VarDictionary will call VarTracker::ReleaseVar. This results in
+ // operation on invalid live_vars_ (they are mid-destruction). Secondary map
+ // prevents invalid operations on live_vars_.
+ VarMap vars;
+ std::swap(vars, live_vars_);
+#endif
+}
void VarTracker::CheckThreadingPreconditions() const {
DCHECK(!thread_checker_ || thread_checker_->CalledOnValidThread());
info.ref_count--;
if (info.ref_count == 0) {
+#if defined(TIZEN_PEPPER_EXTENSIONS)
+ if (!info.var) {
+ live_vars_.erase(found);
+ return false;
+ }
+#endif
+
// Hold a reference to the Var until it is erased so that we don't re-enter
// live_vars_.erase() during deletion.
// TODO(raymes): Make deletion of Vars iterative instead of recursive.
}
int32_t VarTracker::AddVarInternal(Var* var, AddVarRefMode mode) {
+#if defined(TIZEN_PEPPER_EXTENSIONS)
+ if (!var)
+ return 0;
+#endif
+
// If the plugin manages to create millions of strings.
if (last_var_id_ == std::numeric_limits<int32_t>::max() >> kPPIdTypeBits)
return 0;