From 88503347da0b2db37fcd7cffd4129422ab826f79 Mon Sep 17 00:00:00 2001 From: Tim Strazzere Date: Wed, 20 Apr 2016 15:05:23 -0700 Subject: [PATCH] Avoid SIGSEV due to non-existant string section. --- elfio/elfio_strings.hpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/elfio/elfio_strings.hpp b/elfio/elfio_strings.hpp index afcd38b..ac0cfba 100644 --- a/elfio/elfio_strings.hpp +++ b/elfio/elfio_strings.hpp @@ -44,12 +44,14 @@ class string_section_accessor const char* get_string( Elf_Word index ) const { - if ( index < string_section->get_size() ) { - const char* data = string_section->get_data(); - if ( 0 != data ) { - return data + index; + if ( string_section ) { + if ( index < string_section->get_size() ) { + const char* data = string_section->get_data(); + if ( 0 != data ) { + return data + index; + } } - } + } return 0; }