37 m_status = Decoder::no_error; |
37 m_status = Decoder::no_error; |
38 |
38 |
39 // try to load the string table |
39 // try to load the string table |
40 long cur_offset = ftell(file); |
40 long cur_offset = ftell(file); |
41 if (cur_offset != -1) { |
41 if (cur_offset != -1) { |
42 m_symbols = (Elf_Sym*)NEW_C_HEAP_ARRAY(char, shdr.sh_size); |
42 // call malloc so we can back up if memory allocation fails. |
|
43 m_symbols = (Elf_Sym*)os::malloc(shdr.sh_size); |
43 if (m_symbols) { |
44 if (m_symbols) { |
44 if (fseek(file, shdr.sh_offset, SEEK_SET) || |
45 if (fseek(file, shdr.sh_offset, SEEK_SET) || |
45 fread((void*)m_symbols, shdr.sh_size, 1, file) != 1 || |
46 fread((void*)m_symbols, shdr.sh_size, 1, file) != 1 || |
46 fseek(file, cur_offset, SEEK_SET)) { |
47 fseek(file, cur_offset, SEEK_SET)) { |
47 m_status = Decoder::file_invalid; |
48 m_status = Decoder::file_invalid; |
48 FREE_C_HEAP_ARRAY(char, m_symbols); |
49 os::free(m_symbols); |
49 m_symbols = NULL; |
50 m_symbols = NULL; |
50 } |
51 } |
51 } |
52 } |
52 if (m_status == Decoder::no_error) { |
53 if (m_status == Decoder::no_error) { |
53 memcpy(&m_shdr, &shdr, sizeof(Elf_Shdr)); |
54 memcpy(&m_shdr, &shdr, sizeof(Elf_Shdr)); |