[Libva] [PATCH intel-driver] test: fix jpeg decode invalid indexing

Sean V Kelley seanvk at posteo.de
Wed Sep 7 19:26:42 UTC 2016


> On Sep 7, 2016, at 12:22 PM, U. Artie Eoff <ullysses.a.eoff at intel.com> wrote:
> 
> Use hsample and vsample factor in printComponentDataTo to
> avoid invalid indexes into the data array.
> 
> This fixes a segfault in the jpeg fourcc tests that may be
> triggered during 'make check'.
> 
> Signed-off-by: U. Artie Eoff <ullysses.a.eoff at intel.com>


The issue here is really with random garbage in the test as written, not the Gtest project itself.

I suppose enough repeated test loops on the test should trigger the random issue.

applied.

Sean

> ---
> test/i965_jpeg_decode_test.cpp | 65 +++++++++++++++++++++---------------------
> 1 file changed, 32 insertions(+), 33 deletions(-)
> 
> diff --git a/test/i965_jpeg_decode_test.cpp b/test/i965_jpeg_decode_test.cpp
> index 6a17d1e98d18..3a1c68f1fa4d 100644
> --- a/test/i965_jpeg_decode_test.cpp
> +++ b/test/i965_jpeg_decode_test.cpp
> @@ -133,43 +133,42 @@ protected:
>         }
>     }
> 
> -    TestPattern::SharedConst testPattern;
> -    PictureData::SharedConst pd;
> -};
> -
> -void printComponentDataTo(std::ostream& os, const uint8_t * const data,
> -    unsigned w, unsigned h, unsigned pitch)
> -{
> -    os << "    ";
> -    for (unsigned i(0); i < w; ++i)
> -        os << std::setw(4) << i << " ";
> -    os << std::endl;
> -
> -    const uint8_t *row = data;
> -    for (unsigned i(0); i < h; ++i) {
> -        os << std::dec << std::setfill(' ') << std::setw(3) << (i * w) << " ";
> -        for (size_t j(0); j < w; ++j) {
> -            os  << "0x" << std::hex << std::setfill('0') << std::setw(2)
> -                << (uint32_t)row[j] << ",";
> +    void printComponentDataTo(std::ostream& os, const uint8_t * const data,
> +        unsigned w, unsigned h, unsigned pitch, unsigned hsample = 1,
> +        unsigned vsample = 1)
> +    {
> +        const uint8_t *row = data;
> +        for (unsigned i(0); i < (h/vsample); ++i) {
> +            for (size_t j(0); j < (w/hsample); ++j) {
> +                os  << "0x" << std::hex << std::setfill('0') << std::setw(2)
> +                    << (uint32_t)row[j] << ",";
> +            }
> +            os << std::endl;
> +            row += pitch;
>         }
> -        os << std::endl;
> -        row += pitch;
> +        os << std::setw(0) << std::setfill(' ') << std::dec << std::endl;
>     }
> -    os << std::setw(0) << std::setfill(' ') << std::dec << std::endl;
> -}
> 
> -void printImageOutputTo(std::ostream& os, const VAImage& image,
> -    const uint8_t * const output)
> -{
> -    printComponentDataTo(os, output + image.offsets[0], image.width,
> -        image.height, image.pitches[0]); // Y
> -
> -    printComponentDataTo(os, output + image.offsets[1], image.width,
> -        image.height, image.pitches[1]); // U
> +    void printImageOutputTo(std::ostream& os, const VAImage& image,
> +        const uint8_t * const output)
> +    {
> +        printComponentDataTo(os, output + image.offsets[0], image.width,
> +            image.height, image.pitches[0]); // Y
> +
> +        printComponentDataTo(os, output + image.offsets[1], image.width,
> +            image.height, image.pitches[1],
> +            pd->pparam.components[0].h_sampling_factor,
> +            pd->pparam.components[0].v_sampling_factor); // U
> +
> +        printComponentDataTo(os, output + image.offsets[2], image.width,
> +            image.height, image.pitches[2],
> +            pd->pparam.components[0].h_sampling_factor,
> +            pd->pparam.components[0].v_sampling_factor); // V
> +    }
> 
> -    printComponentDataTo(os, output + image.offsets[2], image.width,
> -        image.height, image.pitches[2]); // V
> -}
> +    TestPattern::SharedConst testPattern;
> +    PictureData::SharedConst pd;
> +};
> 
> #define ASSERT_NO_FAILURE(statement) \
>     statement; \
> --
> 2.1.0
> 
> _______________________________________________
> Libva mailing list
> Libva at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/libva

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <https://lists.freedesktop.org/archives/libva/attachments/20160907/877d1001/attachment.sig>


More information about the Libva mailing list