fix inadvertent use of uninitialized variable in dladdr
authorRich Felker <dalias@aerifal.cx>
Sat, 6 Jul 2019 21:47:43 +0000 (17:47 -0400)
committerRich Felker <dalias@aerifal.cx>
Sat, 6 Jul 2019 21:47:43 +0000 (17:47 -0400)
commit c8b49b2fbc7faa8bf065220f11963d76c8a2eb93 introduced code that
checked bestsym to determine whether a matching symbol was found, but
bestsym is uninitialized if not. instead use best, consistent with use
in the rest of the function.

simplified from bug report and patch by Cheng Liu.

ldso/dynlink.c

index db543c19168c1ad6691dd66a282b9aaeafc3419f..d1edb131f7a8e57e1239d325a9149fb148d45e98 100644 (file)
@@ -2217,7 +2217,7 @@ int dladdr(const void *addr_arg, Dl_info *info)
                }
        }
 
-       if (bestsym && besterr > bestsym->st_size-1) {
+       if (best && besterr > bestsym->st_size-1) {
                best = 0;
                bestsym = 0;
        }