--- a/src/lib/cache.c Tue Dec 29 02:11:27 2009 +0200
+++ b/src/lib/cache.c Tue Dec 29 12:29:50 2009 +0200
@@ -444,7 +444,7 @@
if (ti->x + ti->width > cache->header->width)
clip_x = cache->header->width;
else
- clip_y = ti->x + ti->width;
+ clip_x = ti->x + ti->width;
// figure out if the tile clips over the bottom edge
// XXX: use min()
@@ -491,6 +491,13 @@
{
int err;
+ // check within bounds
+ if (ti->x >= cache->header->width || ti->y >= cache->header->height) {
+ // completely outside
+ errno = EINVAL;
+ return -1;
+ }
+
// ensure open
if (pt_cache_open(cache))
return -1;
--- a/src/lib/pngtile.h Tue Dec 29 02:11:27 2009 +0200
+++ b/src/lib/pngtile.h Tue Dec 29 12:29:50 2009 +0200
@@ -51,7 +51,11 @@
size_t width, height;
};
-/** Info for image tile */
+/**
+ * Info for image tile
+ *
+ * The tile may safely overlap with the edge of the image, but it should not be entirely outside of the image
+ */
struct pt_tile_info {
/** Dimensions of output image */
size_t width, height;