#ifdef USE_MMAP
if (stringsize >= BYTES_IN_WORD)
{
- if (! bfd_get_file_window (abfd, obj_str_filepos (abfd), stringsize,
+ if (! bfd_get_file_window (abfd, obj_str_filepos (abfd), stringsize + 1,
&obj_aout_string_window (abfd), TRUE))
return FALSE;
strings = (char *) obj_aout_string_window (abfd).data;
else
#endif
{
- strings = (char *) bfd_malloc (stringsize);
+ strings = (char *) bfd_malloc (stringsize + 1);
if (strings == NULL)
return FALSE;
/* Ensure that a zero index yields an empty string. */
strings[0] = '\0';
- strings[stringsize - 1] = 0;
+ /* Ensure that the string buffer is NUL terminated. */
+ strings[stringsize] = 0;
obj_aout_external_strings (abfd) = strings;
obj_aout_external_string_size (abfd) = stringsize;
const char *symname;
symname = q->symbol.name;
- if (strcmp (symname + strlen (symname) - 2, ".o") == 0)
+
+ if (symname != NULL
+ && strlen (symname) > 2
+ && strcmp (symname + strlen (symname) - 2, ".o") == 0)
{
if (q->symbol.value > low_line_vma)
{
case N_FUN:
{
/* We'll keep this if it is nearer than the one we have already. */
- if (q->symbol.value >= low_func_vma &&
- q->symbol.value <= offset)
+ if (q->symbol.value >= low_func_vma
+ && q->symbol.value <= offset)
{
low_func_vma = q->symbol.value;
func = (asymbol *)q;