[Libva] [PATCH] Changed 'c' variable 'char' data type to 'int' data type.
Lim, Siew Hoon
siew.hoon.lim at intel.com
Tue Jul 26 11:02:13 UTC 2016
> -----Original Message-----
> From: Xiang, Haihao
> Sent: Friday, July 22, 2016 3:33 PM
> To: Lim, Siew Hoon; libva at lists.freedesktop.org
> Subject: Re: [Libva] [PATCH] Changed 'c' variable 'char' data type to 'int' data
> type.
>
>
> > The getopt_long func is return integer data type is more than 1 bytes.
> > Already access invalid memory location since size of 'c' is char data
> > type.
>
> Your fix is reasonable. But why will it access invalid memory location without
> this fix?
>
[Siew Hoon] Ouch...Totally I can't recall why I go put access invalid memory location.
Today I'm go thru code again, it will be zero chance match with unsigned value "EOF which is -1" where there are no more option for the getopt_long_only will be return "-1" value.
It should be exit in while loop checking statement once getopt_long_only return "-1".
I will modify the commit message re-send this patch tomorrow.
> >
> > Signed-off-by: Lim Siew Hoon <siew.hoon.lim at intel.com>
> > ---
> > test/encode/h264encode.c | 2 +-
> > test/putsurface/putsurface_common.c | 2 +-
> > 2 files changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/test/encode/h264encode.c b/test/encode/h264encode.c index
> > 649b245..8d8ea30 100644
> > --- a/test/encode/h264encode.c
> > +++ b/test/encode/h264encode.c
> > @@ -860,7 +860,7 @@ static int print_help(void)
> >
> > static int process_cmdline(int argc, char *argv[])
> > {
> > - char c;
> > + int c;
> > const struct option long_opts[] = {
> > {"help", no_argument, NULL, 0 },
> > {"bitrate", required_argument, NULL, 1 }, diff --git
> > a/test/putsurface/putsurface_common.c
> > b/test/putsurface/putsurface_common.c
> > index c50c116..fa0249a 100755
> > --- a/test/putsurface/putsurface_common.c
> > +++ b/test/putsurface/putsurface_common.c
> > @@ -514,7 +514,7 @@ int main(int argc,char **argv)
> > VAStatus va_status;
> > pthread_t thread1;
> > int ret;
> > - char c;
> > + int c;
> > int i;
> > char str_src_fmt[5], str_dst_fmt[5];
> >
More information about the Libva
mailing list