Skip to content
  • Milian Wolff's avatar
    Return Declaration from FunctionDefinition::definition · 51c038da
    Milian Wolff authored
    This fixes an UB cast when we call this on a ClassFunctionDeclaration
    with setDeclarationIsDefinition(true) as shown in this UBSAN report:
    
    ```
    /home/milian/projects/kf5/src/extragear/kdevelop/kdevelop/kdevplatform/language/duchain/functiondefinition.cpp:93:49: runtime error: downcast of address 0x6060005c72c0 which does not point to an object of type 'FunctionDefinition'
    0x6060005c72c0: note: object is of type 'KDevelop::ClassFunctionDeclaration'
     26 02 00 76  f0 06 b1 d3 05 7f 00 00  a0 64 21 00 b0 60 00 00  50 6e 22 00 20 60 00 00  10 2b 01 01
                  ^~~~~~~~~~~~~~~~~~~~~~~
                  vptr for 'KDevelop::ClassFunctionDeclaration'
        #0 0x7f05d2c5377f in KDevelop::FunctionDefinition::definition(KDevelop::Declaration const*) /home/milian/projects/kf5/src/extragear/kdevelop/kdevelop/kdevplatform/language/duchain/functiondefinition.cpp:93
        #1 0x7f05dddae858 in accept /home/milian/projects/kf5/src/extragear/kdevelop/kdevelop/plugins/clang/...
    51c038da