summaryrefslogtreecommitdiff
path: root/Kernel/Graphics
diff options
context:
space:
mode:
authorDaniel Bertalan <dani@danielbertalan.dev>2021-09-03 19:11:51 +0200
committerAndreas Kling <kling@serenityos.org>2021-09-03 23:20:23 +0200
commitd7b6cc6421c48185f4dfafb24d2b093b86305860 (patch)
tree7e5ace9318b73d4efe095c43605cd514db1cccaa /Kernel/Graphics
parentbad23e3f8cc9c66d818ddb2f7bbe7bddce5c09e2 (diff)
downloadserenity-d7b6cc6421c48185f4dfafb24d2b093b86305860.zip
Everywhere: Prevent risky implicit casts of (Nonnull)RefPtr
Our existing implementation did not check the element type of the other pointer in the constructors and move assignment operators. This meant that some operations that would require explicit casting on raw pointers were done implicitly, such as: - downcasting a base class to a derived class (e.g. `Kernel::Inode` => `Kernel::ProcFSDirectoryInode` in Kernel/ProcFS.cpp), - casting to an unrelated type (e.g. `Promise<bool>` => `Promise<Empty>` in LibIMAP/Client.cpp) This, of course, allows gross violations of the type system, and makes the need to type-check less obvious before downcasting. Luckily, while adding the `static_ptr_cast`s, only two truly incorrect usages were found; in the other instances, our casts just needed to be made explicit.
Diffstat (limited to 'Kernel/Graphics')
-rw-r--r--Kernel/Graphics/GraphicsManagement.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/Kernel/Graphics/GraphicsManagement.cpp b/Kernel/Graphics/GraphicsManagement.cpp
index a3607dcbcc..2455cd74bf 100644
--- a/Kernel/Graphics/GraphicsManagement.cpp
+++ b/Kernel/Graphics/GraphicsManagement.cpp
@@ -130,7 +130,7 @@ UNMAP_AFTER_INIT bool GraphicsManagement::determine_and_initialize_graphics_devi
// Note: If no other VGA adapter is attached as m_vga_adapter, we should attach it then.
if (!m_vga_adapter && PCI::is_io_space_enabled(address) && adapter->type() == GraphicsDevice::Type::VGACompatible) {
dbgln("Graphics adapter @ {} is operating in VGA mode", address);
- m_vga_adapter = adapter;
+ m_vga_adapter = static_ptr_cast<VGACompatibleAdapter>(adapter);
}
return true;
}