projects
/
deliverable
/
binutils-gdb.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Inline abbrev lookup
[deliverable/binutils-gdb.git]
/
binutils
/
wrstabs.c
diff --git
a/binutils/wrstabs.c
b/binutils/wrstabs.c
index 0ca861ce8d84b4b9dbdc0d9a1c11c72bbf673b90..0deed3151a3c9032440d8f27b374380ce36da8d9 100644
(file)
--- a/
binutils/wrstabs.c
+++ b/
binutils/wrstabs.c
@@
-1,6
+1,5
@@
/* wrstabs.c -- Output stabs debugging information
/* wrstabs.c -- Output stabs debugging information
- Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2006,
- 2007, 2009 Free Software Foundation, Inc.
+ Copyright (C) 1996-2020 Free Software Foundation, Inc.
Written by Ian Lance Taylor <ian@cygnus.com>.
This file is part of GNU Binutils.
Written by Ian Lance Taylor <ian@cygnus.com>.
This file is part of GNU Binutils.
@@
-438,7
+437,8
@@
stab_pop_type (struct stab_write_handle *info)
char *ret;
s = info->type_stack;
char *ret;
s = info->type_stack;
- assert (s != NULL);
+ if (s == NULL)
+ return NULL;
info->type_stack = s->next;
info->type_stack = s->next;
@@
-512,7
+512,8
@@
write_stabs_in_sections_debugging_info (bfd *abfd, void *dhandle,
if (! debug_write (dhandle, &stab_fns, (void *) &info))
return FALSE;
if (! debug_write (dhandle, &stab_fns, (void *) &info))
return FALSE;
- assert (info.pending_lbrac == (bfd_vma) -1);
+ if (info.pending_lbrac != (bfd_vma) -1)
+ return FALSE;
/* Output a trailing N_SO. */
if (! stab_write_symbol (&info, N_SO, 0, info.last_text_address,
/* Output a trailing N_SO. */
if (! stab_write_symbol (&info, N_SO, 0, info.last_text_address,
@@
-789,7
+790,8
@@
stab_enum_type (void *p, const char *tag, const char **names,
if (names == NULL)
{
if (names == NULL)
{
- assert (tag != NULL);
+ if (tag == NULL)
+ return FALSE;
buf = (char *) xmalloc (10 + strlen (tag));
sprintf (buf, "xe%s:", tag);
buf = (char *) xmalloc (10 + strlen (tag));
sprintf (buf, "xe%s:", tag);
@@
-851,7
+853,8
@@
stab_modify_type (struct stab_write_handle *info, int mod,
long tindex;
char *s, *buf;
long tindex;
char *s, *buf;
- assert (info->type_stack != NULL);
+ if (info->type_stack == NULL)
+ return FALSE;
targindex = info->type_stack->index;
if (targindex <= 0
targindex = info->type_stack->index;
if (targindex <= 0
@@
-1221,8
+1224,7
@@
stab_method_type (void *p, bfd_boolean domainp, int argcount,
}
strcat (buf, ";");
}
strcat (buf, ";");
- if (args != NULL)
- free (args);
+ free (args);
if (! stab_push_string (info, buf, 0, definition, 0))
return FALSE;
if (! stab_push_string (info, buf, 0, definition, 0))
return FALSE;
@@
-1312,9
+1314,7
@@
stab_start_struct_type (void *p, const char *tag, unsigned int id,
struct stab_write_handle *info = (struct stab_write_handle *) p;
long tindex;
bfd_boolean definition;
struct stab_write_handle *info = (struct stab_write_handle *) p;
long tindex;
bfd_boolean definition;
- char *buf;
-
- buf = (char *) xmalloc (40);
+ char buf[40];
if (id == 0)
{
if (id == 0)
{
@@
-1363,8
+1363,9
@@
stab_struct_field (void *p, const char *name, bfd_vma bitpos,
/* Add this field to the end of the current struct fields, which is
currently on the top of the stack. */
/* Add this field to the end of the current struct fields, which is
currently on the top of the stack. */
+ if (info->type_stack->fields == NULL)
+ return FALSE;
- assert (info->type_stack->fields != NULL);
n = (char *) xmalloc (strlen (info->type_stack->fields)
+ strlen (name)
+ strlen (s)
n = (char *) xmalloc (strlen (info->type_stack->fields)
+ strlen (name)
+ strlen (s)
@@
-1419,7
+1420,8
@@
stab_end_struct_type (void *p)
unsigned int size;
char *fields, *first, *buf;
unsigned int size;
char *fields, *first, *buf;
- assert (info->type_stack != NULL && info->type_stack->fields != NULL);
+ if (info->type_stack == NULL || info->type_stack->fields == NULL)
+ return FALSE;
definition = info->type_stack->definition;
tindex = info->type_stack->index;
definition = info->type_stack->definition;
tindex = info->type_stack->index;
@@
-1443,18
+1445,15
@@
stab_end_struct_type (void *p)
/* Start outputting a class. */
static bfd_boolean
/* Start outputting a class. */
static bfd_boolean
-stab_start_class_type (void *p, const char *tag, unsigned int id, bfd_boolean structp, unsigned int size, bfd_boolean vptr, bfd_boolean ownvptr)
+stab_start_class_type (void *p, const char *tag, unsigned int id,
+ bfd_boolean structp, unsigned int size,
+ bfd_boolean vptr, bfd_boolean ownvptr)
{
struct stab_write_handle *info = (struct stab_write_handle *) p;
{
struct stab_write_handle *info = (struct stab_write_handle *) p;
- bfd_boolean definition;
- char *vstring;
+ bfd_boolean definition
= FALSE
;
+ char *vstring
= NULL
;
- if (! vptr || ownvptr)
- {
- definition = FALSE;
- vstring = NULL;
- }
- else
+ if (vptr && !ownvptr)
{
definition = info->type_stack->definition;
vstring = stab_pop_type (info);
{
definition = info->type_stack->definition;
vstring = stab_pop_type (info);
@@
-1469,23
+1468,24
@@
stab_start_class_type (void *p, const char *tag, unsigned int id, bfd_boolean st
if (ownvptr)
{
if (ownvptr)
{
- assert (info->type_stack->index > 0);
+ if (info->type_stack->index < 1)
+ return FALSE;
vtable = (char *) xmalloc (20);
sprintf (vtable, "~%%%ld", info->type_stack->index);
}
else
{
vtable = (char *) xmalloc (20);
sprintf (vtable, "~%%%ld", info->type_stack->index);
}
else
{
+ if (vstring == NULL)
+ return FALSE;
vtable = (char *) xmalloc (strlen (vstring) + 3);
sprintf (vtable, "~%%%s", vstring);
free (vstring);
vtable = (char *) xmalloc (strlen (vstring) + 3);
sprintf (vtable, "~%%%s", vstring);
free (vstring);
+ if (definition)
+ info->type_stack->definition = TRUE;
}
}
-
info->type_stack->vtable = vtable;
}
info->type_stack->vtable = vtable;
}
- if (definition)
- info->type_stack->definition = TRUE;
-
return TRUE;
}
return TRUE;
}
@@
-1506,7
+1506,8
@@
stab_class_static_member (void *p, const char *name, const char *physname,
/* Add this field to the end of the current struct fields, which is
currently on the top of the stack. */
/* Add this field to the end of the current struct fields, which is
currently on the top of the stack. */
- assert (info->type_stack->fields != NULL);
+ if (info->type_stack->fields == NULL)
+ return FALSE;
n = (char *) xmalloc (strlen (info->type_stack->fields)
+ strlen (name)
+ strlen (s)
n = (char *) xmalloc (strlen (info->type_stack->fields)
+ strlen (name)
+ strlen (s)
@@
-1586,7
+1587,8
@@
stab_class_baseclass (void *p, bfd_vma bitpos, bfd_boolean is_virtual,
/* Add the new baseclass to the existing ones. */
/* Add the new baseclass to the existing ones. */
- assert (info->type_stack != NULL && info->type_stack->fields != NULL);
+ if (info->type_stack == NULL || info->type_stack->fields == NULL)
+ return FALSE;
if (info->type_stack->baseclasses == NULL)
c = 0;
if (info->type_stack->baseclasses == NULL)
c = 0;
@@
-1618,7
+1620,8
@@
stab_class_start_method (void *p, const char *name)
struct stab_write_handle *info = (struct stab_write_handle *) p;
char *m;
struct stab_write_handle *info = (struct stab_write_handle *) p;
char *m;
- assert (info->type_stack != NULL && info->type_stack->fields != NULL);
+ if (info->type_stack == NULL || info->type_stack->fields == NULL)
+ return FALSE;
if (info->type_stack->methods == NULL)
{
if (info->type_stack->methods == NULL)
{
@@
-1663,7
+1666,8
@@
stab_class_method_var (struct stab_write_handle *info, const char *physname,
context = stab_pop_type (info);
}
context = stab_pop_type (info);
}
- assert (info->type_stack != NULL && info->type_stack->methods != NULL);
+ if (info->type_stack == NULL || info->type_stack->methods == NULL)
+ return FALSE;
switch (visibility)
{
switch (visibility)
{
@@
-1764,7
+1768,8
@@
stab_class_end_method (void *p)
{
struct stab_write_handle *info = (struct stab_write_handle *) p;
{
struct stab_write_handle *info = (struct stab_write_handle *) p;
- assert (info->type_stack != NULL && info->type_stack->methods != NULL);
+ if (info->type_stack == NULL || info->type_stack->methods == NULL)
+ return FALSE;
/* We allocated enough room on info->type_stack->methods to add the
trailing semicolon. */
/* We allocated enough room on info->type_stack->methods to add the
trailing semicolon. */
@@
-1783,7
+1788,10
@@
stab_end_class_type (void *p)
unsigned int i = 0;
char *buf;
unsigned int i = 0;
char *buf;
- assert (info->type_stack != NULL && info->type_stack->fields != NULL);
+ if (info->type_stack == NULL
+ || info->type_stack->string == NULL
+ || info->type_stack->fields == NULL)
+ return FALSE;
/* Work out the size we need to allocate for the class definition. */
/* Work out the size we need to allocate for the class definition. */
@@
-1856,7
+1864,8
@@
stab_typedef_type (void *p, const char *name)
struct string_hash_entry *h;
h = string_hash_lookup (&info->typedef_hash, name, FALSE, FALSE);
struct string_hash_entry *h;
h = string_hash_lookup (&info->typedef_hash, name, FALSE, FALSE);
- assert (h != NULL && h->index > 0);
+ if (h == NULL || h->index < 1)
+ return FALSE;
return stab_push_defined_type (info, h->index, h->size);
}
return stab_push_defined_type (info, h->index, h->size);
}
@@
-2088,7
+2097,8
@@
stab_start_function (void *p, const char *name, bfd_boolean globalp)
struct stab_write_handle *info = (struct stab_write_handle *) p;
char *rettype, *buf;
struct stab_write_handle *info = (struct stab_write_handle *) p;
char *rettype, *buf;
- assert (info->nesting == 0 && info->fun_offset == -1);
+ if (info->nesting != 0 || info->fun_offset != -1)
+ return FALSE;
rettype = stab_pop_type (info);
rettype = stab_pop_type (info);
@@
-2230,7
+2240,8
@@
stab_end_block (void *p, bfd_vma addr)
info->pending_lbrac = (bfd_vma) -1;
}
info->pending_lbrac = (bfd_vma) -1;
}
- assert (info->nesting > 0);
+ if (info->nesting < 1)
+ return FALSE;
--info->nesting;
--info->nesting;
@@
-2257,7
+2268,8
@@
stab_lineno (void *p, const char *file, unsigned long lineno, bfd_vma addr)
{
struct stab_write_handle *info = (struct stab_write_handle *) p;
{
struct stab_write_handle *info = (struct stab_write_handle *) p;
- assert (info->lineno_filename != NULL);
+ if (info->lineno_filename == NULL)
+ return FALSE;
if (addr > info->last_text_address)
info->last_text_address = addr;
if (addr > info->last_text_address)
info->last_text_address = addr;
This page took
0.028558 seconds
and
4
git commands to generate.