From: Gary Lin <glin@suse.com>
To: Dandan Bi <dandan.bi@intel.com>
Cc: edk2-devel@lists.01.org, Eric Dong <eric.dong@intel.com>,
Liming Gao <liming.gao@intel.com>
Subject: Re: [patch] BaseTools/VfrCompile: Avoid using uninitialized pointer
Date: Wed, 9 May 2018 10:31:44 +0800 [thread overview]
Message-ID: <20180509023144.n2iwuwlunwnmwv45@GaryWorkstation> (raw)
In-Reply-To: <20180508114620.78328-1-dandan.bi@intel.com>
On Tue, May 08, 2018 at 07:46:19PM +0800, Dandan Bi wrote:
> _CLEAR_SAVED_OPHDR () is used for initialize the variables.
> We should not update it to free memory.
> It will cause some pointer used before initialization.
> This patch is to fix this issue.
>
> Cc: Eric Dong <eric.dong@intel.com>
> Cc: Liming Gao <liming.gao@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Dandan Bi <dandan.bi@intel.com>
> ---
> BaseTools/Source/C/VfrCompile/VfrSyntax.g | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/BaseTools/Source/C/VfrCompile/VfrSyntax.g b/BaseTools/Source/C/VfrCompile/VfrSyntax.g
> index 4b0a43606ea..cc042ab4307 100644
> --- a/BaseTools/Source/C/VfrCompile/VfrSyntax.g
> +++ b/BaseTools/Source/C/VfrCompile/VfrSyntax.g
> @@ -4103,12 +4103,15 @@ vfrStatementExpression [UINT32 RootLevel, UINT32 ExpOpCount = 0] :
> }
> }
> }
>
> if ($RootLevel == 0) {
> - _CLEAR_SAVED_OPHDR ();
> - mCIfrOpHdrIndex --;
> + if (mCIfrOpHdr[mCIfrOpHdrIndex] != NULL) {
> + delete mCIfrOpHdr[mCIfrOpHdrIndex];
> + mCIfrOpHdr[mCIfrOpHdrIndex] = NULL;
> + }
> + mCIfrOpHdrIndex --;
An extra space was added.
> }
> >>
> ;
>
> //
> @@ -5082,14 +5085,11 @@ EfiVfrParser::_SAVE_OPHDR_COND (
> VOID
> EfiVfrParser::_CLEAR_SAVED_OPHDR (
> VOID
> )
> {
> - if (mCIfrOpHdr[mCIfrOpHdrIndex] != NULL) {
> - delete mCIfrOpHdr[mCIfrOpHdrIndex];
> - mCIfrOpHdr[mCIfrOpHdrIndex] = NULL;
> - }
> + mCIfrOpHdr[mCIfrOpHdrIndex] = NULL;
> mCIfrOpHdrLineNo[mCIfrOpHdrIndex] = 0;
> }
>
> BOOLEAN
> EfiVfrParser::_SET_SAVED_OPHDR_SCOPE (
> --
I applied the patch and triggered the rebuild of ovmf. It's now built on
all versions and arch.
Thanks for fixing it.
Tested-by: Gary Lin <glin@suse.com>
> 2.14.3.windows.1
>
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
>
next prev parent reply other threads:[~2018-05-09 2:32 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-08 11:46 [patch] BaseTools/VfrCompile: Avoid using uninitialized pointer Dandan Bi
2018-05-09 2:31 ` Gary Lin [this message]
2018-05-09 5:09 ` Bi, Dandan
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-list 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=20180509023144.n2iwuwlunwnmwv45@GaryWorkstation \
--to=devel@edk2.groups.io \
/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