Skip to content

Commit

Permalink
Resolve issue of potential double free in test
Browse files Browse the repository at this point in the history
GitOrigin-RevId: 75d78221bf040035968680cfbde11d776db9800d
  • Loading branch information
Vertexwahn committed May 19, 2024
1 parent 0f1fa13 commit 4fcb29a
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions devertexwahn/imaging/tests/third_party/libpng_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,21 @@ TEST(libpng, load_png_test) {

ASSERT_TRUE(false);
}
else {
png_init_io(png_ptr, fp);

png_init_io(png_ptr, fp);
unsigned int sig_read = 0;
png_set_sig_bytes(png_ptr, sig_read);

unsigned int sig_read = 0;
png_set_sig_bytes(png_ptr, sig_read);
png_read_png(png_ptr, info_ptr, PNG_TRANSFORM_STRIP_16 | PNG_TRANSFORM_PACKING | PNG_TRANSFORM_EXPAND, png_voidp_NULL);

png_read_png(png_ptr, info_ptr, PNG_TRANSFORM_STRIP_16 | PNG_TRANSFORM_PACKING | PNG_TRANSFORM_EXPAND, png_voidp_NULL);
int width = png_get_image_width(png_ptr, info_ptr);
int height = png_get_image_height(png_ptr, info_ptr);

int width = png_get_image_width(png_ptr, info_ptr);
int height = png_get_image_height(png_ptr, info_ptr);
EXPECT_THAT(width, 400);
EXPECT_THAT(height, 400);

EXPECT_THAT(width, 400);
EXPECT_THAT(height, 400);

png_destroy_read_struct(&png_ptr, &info_ptr, nullptr);
fclose(fp);
png_destroy_read_struct(&png_ptr, &info_ptr, nullptr);
fclose(fp);
}
}

0 comments on commit 4fcb29a

Please sign in to comment.