[libpng12] Avoid out-of-bounds memory access while checking version string in

pngread.c and pngwrite.c