src/share/vm/utilities/elfStringTable.cpp

Print this page

        

*** 65,89 **** if (m_next != NULL) { delete m_next; } } ! const char* ElfStringTable::string_at(int pos) { ! if (m_status != Decoder::no_error) { ! return NULL; } if (m_table != NULL) { ! return (const char*)(m_table + pos); } else { long cur_pos = ftell(m_file); if (cur_pos == -1 || fseek(m_file, m_shdr.sh_offset + pos, SEEK_SET) || ! fread(m_symbol, 1, MAX_SYMBOL_LEN, m_file) <= 0 || fseek(m_file, cur_pos, SEEK_SET)) { m_status = Decoder::file_invalid; ! return NULL; } ! return (const char*)m_symbol; } } #endif // _WINDOWS --- 65,90 ---- if (m_next != NULL) { delete m_next; } } ! bool ElfStringTable::string_at(int pos, char* buf, int buflen) { ! if (Decoder::is_error(m_status)) { ! return false; } if (m_table != NULL) { ! jio_snprintf(buf, buflen, "%s", (const char*)(m_table + pos)); ! return true; } else { long cur_pos = ftell(m_file); if (cur_pos == -1 || fseek(m_file, m_shdr.sh_offset + pos, SEEK_SET) || ! fread(buf, 1, buflen, m_file) <= 0 || fseek(m_file, cur_pos, SEEK_SET)) { m_status = Decoder::file_invalid; ! return false; } ! return true; } } #endif // _WINDOWS