py/objtype: Validate super() arguments.

This fixes various null dereferencing and out-of-bounds access because
super_attr assumes the held obj is effectively an object of the held type,
which is now verified.

Fixes issue #12830.

Signed-off-by: stijn <stijn@ignitron.net>
This commit is contained in:
stijn
2023-11-08 16:42:56 +01:00
committed by Damien George
parent d1bf0eeb0f
commit 093d0c0a17
2 changed files with 23 additions and 1 deletions

View File

@@ -0,0 +1,15 @@
# Check that super rejects invalid arguments.
try:
super(str, 0)
except TypeError:
print("TypeError")
try:
super(str, int)
except TypeError:
print("TypeError")
try:
super(0, int)
except TypeError:
print("TypeError")