python: Don't try setting the parent of null SimObject pointers.

The line of code which would have added the null SimObject as a child
was already guarded by an if, but the line before it which would set the
parent of the null SimObject itself was not. This change moves it into
the if as well.

Change-Id: Icfbc0e87e0ab55917735f720de4e94c19185df46
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/44387
Reviewed-by: Daniel Carvalho <odanrc@yahoo.com.br>
Maintainer: Gabe Black <gabe.black@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
Gabe Black
2021-04-11 02:11:12 -07:00
parent 6334ef4701
commit 0abef82db8

View File

@@ -1487,8 +1487,8 @@ class SimObject(object, metaclass=MetaSimObject):
# exposed by a buggy script. Changes here will probably not be
# exercised without specialized testing.
self.clear_child(name)
child.set_parent(self, name)
if not isNullPointer(child):
child.set_parent(self, name)
self._children[name] = child
# Take SimObject-valued parameters that haven't been explicitly