[llvm-rc] Use cast<> instead of dyn_cast<> to avoid dereference of nullptr
authorSimon Pilgrim <llvm-dev@redking.me.uk>
Wed, 2 Feb 2022 15:35:46 +0000 (15:35 +0000)
committerSimon Pilgrim <llvm-dev@redking.me.uk>
Wed, 2 Feb 2022 15:36:01 +0000 (15:36 +0000)
The pointer is dereferenced immediately, so assert the cast is correct instead of returning nullptr

llvm/tools/llvm-rc/ResourceFileWriter.cpp

index 60287a3..8662320 100644 (file)
@@ -875,7 +875,7 @@ Error ResourceFileWriter::visitIconOrCursorResource(const RCResource *Base) {
     FileStr = IconRes->IconLoc;
     Type = IconCursorGroupType::Icon;
   } else {
-    auto *CursorRes = dyn_cast<CursorResource>(Base);
+    auto *CursorRes = cast<CursorResource>(Base);
     FileStr = CursorRes->CursorLoc;
     Type = IconCursorGroupType::Cursor;
   }