mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-01 15:18:06 +00:00
LibJS: Ensure JS::Date has a key function and its vtable is in LibJS
Without a key function, the vtable for this class can be emitted into every shared object or executable that needs it. This can cause bugs and bad behavior when trying to access the vtable or RTTI for the class. This is most easily seen when trying to call ``is<JS::Date>``, which currently will do a dynamic_cast. Based on compiler, linker and loader choices about ordering, it's possible that the code checking the RTTI and the code that created the object could have a different vtable and type_info in mind, causing false negatives for the ``is`` check.
This commit is contained in:
parent
23600fd76e
commit
6047f1adcb
Notes:
sideshowbarker
2024-07-18 05:01:22 +09:00
Author: https://github.com/ADKaster
Commit: 6047f1adcb
Pull-request: https://github.com/SerenityOS/serenity/pull/22675
Reviewed-by: https://github.com/shannonbooth ✅
2 changed files with 4 additions and 1 deletions
|
@ -36,6 +36,8 @@ Date::Date(double date_value, Object& prototype)
|
|||
{
|
||||
}
|
||||
|
||||
Date::~Date() = default;
|
||||
|
||||
ErrorOr<String> Date::iso_date_string() const
|
||||
{
|
||||
int year = year_from_time(m_date_value);
|
||||
|
|
|
@ -19,7 +19,8 @@ class Date final : public Object {
|
|||
public:
|
||||
static NonnullGCPtr<Date> create(Realm&, double date_value);
|
||||
|
||||
virtual ~Date() override = default;
|
||||
// Out of line to ensure we have a key function
|
||||
virtual ~Date() override;
|
||||
|
||||
double date_value() const { return m_date_value; }
|
||||
void set_date_value(double value) { m_date_value = value; }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue