]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
coredump: check return of dwarf_getscopes
authorLuca Boccassi <luca.boccassi@microsoft.com>
Tue, 30 Nov 2021 02:01:53 +0000 (02:01 +0000)
committerLuca Boccassi <luca.boccassi@microsoft.com>
Tue, 30 Nov 2021 16:49:58 +0000 (16:49 +0000)
src/coredump/stacktrace.c

index a028166f8584052a20d21afbd8d82b32e8990e46..24ea087d382e8f787e397b242c64e068083d5d32 100644 (file)
@@ -60,22 +60,23 @@ static int frame_callback(Dwfl_Frame *frame, void *userdata) {
                 cudie = dwfl_module_addrdie(module, pc_adjusted, &bias);
                 if (cudie) {
                         n = dwarf_getscopes(cudie, pc_adjusted - bias, &scopes);
-                        for (s = scopes; s < scopes + n; s++) {
-                                if (IN_SET(dwarf_tag(s), DW_TAG_subprogram, DW_TAG_inlined_subroutine, DW_TAG_entry_point)) {
-                                        Dwarf_Attribute *a, space;
-
-                                        a = dwarf_attr_integrate(s, DW_AT_MIPS_linkage_name, &space);
-                                        if (!a)
-                                                a = dwarf_attr_integrate(s, DW_AT_linkage_name, &space);
-                                        if (a)
-                                                symbol = dwarf_formstring(a);
-                                        if (!symbol)
-                                                symbol = dwarf_diename(s);
-
-                                        if (symbol)
-                                                break;
+                        if (n > 0)
+                                for (s = scopes; s && s < scopes + n; s++) {
+                                        if (IN_SET(dwarf_tag(s), DW_TAG_subprogram, DW_TAG_inlined_subroutine, DW_TAG_entry_point)) {
+                                                Dwarf_Attribute *a, space;
+
+                                                a = dwarf_attr_integrate(s, DW_AT_MIPS_linkage_name, &space);
+                                                if (!a)
+                                                        a = dwarf_attr_integrate(s, DW_AT_linkage_name, &space);
+                                                if (a)
+                                                        symbol = dwarf_formstring(a);
+                                                if (!symbol)
+                                                        symbol = dwarf_diename(s);
+
+                                                if (symbol)
+                                                        break;
+                                        }
                                 }
-                        }
                 }
 
                 if (!symbol)