* [patch] memory leak in p-exp.y
@ 2007-06-28 21:49 msnyder
2007-07-01 15:43 ` Daniel Jacobowitz
2007-07-03 1:01 ` msnyder
0 siblings, 2 replies; 3+ messages in thread
From: msnyder @ 2007-06-28 21:49 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 25 bytes --]
As flagged by Coverity.
[-- Attachment #2: uptok --]
[-- Type: application/octet-stream, Size: 4650 bytes --]
2007-06-28 Michael Snyder <msnyder@access-company.com>
* p-exp.y (yylex): Memory leak, 'uptokstart' must be freed (Coverity).
Index: p-exp.y
===================================================================
RCS file: /cvs/src/src/gdb/p-exp.y,v
retrieving revision 1.35
diff -p -r1.35 p-exp.y
*** p-exp.y 12 Jun 2007 15:33:04 -0000 1.35
--- p-exp.y 28 Jun 2007 21:38:42 -0000
*************** yylex ()
*** 1342,1347 ****
--- 1342,1348 ----
removed from the input stream. */
if (namelen == 2 && uptokstart[0] == 'I' && uptokstart[1] == 'F')
{
+ free (uptokstart);
return 0;
}
*************** yylex ()
*** 1354,1371 ****
{
case 6:
if (DEPRECATED_STREQ (uptokstart, "OBJECT"))
! return CLASS;
if (DEPRECATED_STREQ (uptokstart, "RECORD"))
! return STRUCT;
if (DEPRECATED_STREQ (uptokstart, "SIZEOF"))
! return SIZEOF;
break;
case 5:
if (DEPRECATED_STREQ (uptokstart, "CLASS"))
! return CLASS;
if (DEPRECATED_STREQ (uptokstart, "FALSE"))
{
yylval.lval = 0;
return FALSEKEYWORD;
}
break;
--- 1355,1385 ----
{
case 6:
if (DEPRECATED_STREQ (uptokstart, "OBJECT"))
! {
! free (uptokstart);
! return CLASS;
! }
if (DEPRECATED_STREQ (uptokstart, "RECORD"))
! {
! free (uptokstart);
! return STRUCT;
! }
if (DEPRECATED_STREQ (uptokstart, "SIZEOF"))
! {
! free (uptokstart);
! return SIZEOF;
! }
break;
case 5:
if (DEPRECATED_STREQ (uptokstart, "CLASS"))
! {
! free (uptokstart);
! return CLASS;
! }
if (DEPRECATED_STREQ (uptokstart, "FALSE"))
{
yylval.lval = 0;
+ free (uptokstart);
return FALSEKEYWORD;
}
break;
*************** yylex ()
*** 1373,1378 ****
--- 1387,1393 ----
if (DEPRECATED_STREQ (uptokstart, "TRUE"))
{
yylval.lval = 1;
+ free (uptokstart);
return TRUEKEYWORD;
}
if (DEPRECATED_STREQ (uptokstart, "SELF"))
*************** yylex ()
*** 1384,1390 ****
if (lookup_symbol (this_name, expression_context_block,
VAR_DOMAIN, (int *) NULL,
(struct symtab **) NULL))
! return THIS;
}
break;
default:
--- 1399,1408 ----
if (lookup_symbol (this_name, expression_context_block,
VAR_DOMAIN, (int *) NULL,
(struct symtab **) NULL))
! {
! free (uptokstart);
! return THIS;
! }
}
break;
default:
*************** yylex ()
*** 1401,1406 ****
--- 1419,1425 ----
so in expression to enter hexadecimal values
we still need to use C syntax with 0xff */
write_dollar_variable (yylval.sval);
+ free (uptokstart);
return VARIABLE;
}
*************** yylex ()
*** 1493,1498 ****
--- 1512,1518 ----
strncpy (tempbuf, tokstart, namelen); tempbuf [namelen] = 0;
yylval.sval.ptr = tempbuf;
yylval.sval.length = namelen;
+ free (uptokstart);
return FIELDNAME;
}
/* Call lookup_symtab, not lookup_partial_symtab, in case there are
*************** yylex ()
*** 1503,1508 ****
--- 1523,1529 ----
{
yylval.ssym.sym = sym;
yylval.ssym.is_a_field_of_this = is_a_field_of_this;
+ free (uptokstart);
return BLOCKNAME;
}
if (sym && SYMBOL_CLASS (sym) == LOC_TYPEDEF)
*************** yylex ()
*** 1593,1605 ****
#else /* not 0 */
yylval.tsym.type = SYMBOL_TYPE (sym);
#endif /* not 0 */
return TYPENAME;
}
yylval.tsym.type
= language_lookup_primitive_type_by_name (current_language,
current_gdbarch, tmp);
if (yylval.tsym.type != NULL)
! return TYPENAME;
/* Input names that aren't symbols but ARE valid hex numbers,
when the input radix permits them, can be names or numbers
--- 1614,1630 ----
#else /* not 0 */
yylval.tsym.type = SYMBOL_TYPE (sym);
#endif /* not 0 */
+ free (uptokstart);
return TYPENAME;
}
yylval.tsym.type
= language_lookup_primitive_type_by_name (current_language,
current_gdbarch, tmp);
if (yylval.tsym.type != NULL)
! {
! free (uptokstart);
! return TYPENAME;
! }
/* Input names that aren't symbols but ARE valid hex numbers,
when the input radix permits them, can be names or numbers
*************** yylex ()
*** 1614,1619 ****
--- 1639,1645 ----
{
yylval.ssym.sym = sym;
yylval.ssym.is_a_field_of_this = is_a_field_of_this;
+ free (uptokstart);
return NAME_OR_INT;
}
}
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-07-03 1:01 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-06-28 21:49 [patch] memory leak in p-exp.y msnyder
2007-07-01 15:43 ` Daniel Jacobowitz
2007-07-03 1:01 ` msnyder
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox