* libdw/dwarf_filesrc.c (dwarf_filesrc): Use dwarf_lock.

Signed-off-by: Aaron Merey <ame...@redhat.com>

---
 libdw/dwarf_filesrc.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/libdw/dwarf_filesrc.c b/libdw/dwarf_filesrc.c
index d866ce72..a0881f36 100644
--- a/libdw/dwarf_filesrc.c
+++ b/libdw/dwarf_filesrc.c
@@ -38,14 +38,23 @@ const char *
 dwarf_filesrc (Dwarf_Files *file, size_t idx, Dwarf_Word *mtime,
               Dwarf_Word *length)
 {
-  if (file == NULL || idx >= file->nfiles)
+  if (file == NULL)
     return NULL;
 
+  mutex_lock (file->dbg->dwarf_lock);
+  if (idx >= file->nfiles)
+    {
+      mutex_unlock (file->dbg->dwarf_lock);
+      return NULL;
+    }
+
   if (mtime != NULL)
     *mtime = file->info[idx].mtime;
 
   if (length != NULL)
     *length = file->info[idx].length;
 
-  return file->info[idx].name;
+  const char *res = file->info[idx].name;
+  mutex_unlock (file->dbg->dwarf_lock);
+  return res;
 }
-- 
2.47.1

Reply via email to