diff options
| author | Amitay Isaacs <amitay@ozlabs.org> | 2018-08-16 15:57:56 +1000 |
|---|---|---|
| committer | Alistair Popple <alistair@popple.id.au> | 2018-09-07 15:24:44 +1000 |
| commit | 0e4c5ac11e7eb70fb7a7c6ab78d8615c9742cf0e (patch) | |
| tree | 8067070e0edd648729c411c68782fafc6bb074f0 | |
| parent | 95a7cb669646ef02dc8647818383bc557e0bf7f1 (diff) | |
| download | pdbg-0e4c5ac11e7eb70fb7a7c6ab78d8615c9742cf0e.tar.gz pdbg-0e4c5ac11e7eb70fb7a7c6ab78d8615c9742cf0e.zip | |
libpdbg: Return immediate parent if class is NULL
This avoids the segfault if class is NULL. Also, this api can be used
to traverse the tree by explicitly setting class=NULL.
Signed-off-by: Amitay Isaacs <amitay@ozlabs.org>
| -rw-r--r-- | libpdbg/libpdbg.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/libpdbg/libpdbg.c b/libpdbg/libpdbg.c index 522bec9..810e045 100644 --- a/libpdbg/libpdbg.c +++ b/libpdbg/libpdbg.c @@ -89,6 +89,9 @@ struct pdbg_target *pdbg_target_parent(const char *class, struct pdbg_target *ta { struct pdbg_target *parent; + if (!class) + return target->parent; + for (parent = target->parent; parent && parent->parent; parent = parent->parent) { if (!strcmp(class, pdbg_target_class_name(parent))) return parent; |

