[libpng16] Add "free()" and "png_free_image()" calls to example code.
diff --git a/example.c b/example.c
index e8bfdd0..c63ef1c 100644
--- a/example.c
+++ b/example.c
@@ -97,6 +97,19 @@
exit(0);
}
}
+
+ else
+ {
+ /* Calling png_free_image is optional unless the simplified API was
+ * not run to completion. In this case if there wasn't enough
+ * memory for 'buffer' we didn't complete the read, so we must free
+ * the image:
+ */
+ if (buffer == NULL)
+ png_free_image(&image);
+
+ else
+ free(buffer);
}
/* Something went wrong reading or writing the image. libpng stores a