From: msnyder@sonic.net
To: gdb-patches@sourceware.org
Subject: [patch] memory leak in p-exp.y
Date: Thu, 28 Jun 2007 21:49:00 -0000 [thread overview]
Message-ID: <24330.12.7.175.2.1183066948.squirrel@webmail.sonic.net> (raw)
[-- 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;
}
}
next reply other threads:[~2007-06-28 21:42 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-28 21:49 msnyder [this message]
2007-07-01 15:43 ` Daniel Jacobowitz
2007-07-03 1:01 ` msnyder
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=24330.12.7.175.2.1183066948.squirrel@webmail.sonic.net \
--to=msnyder@sonic.net \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox