fc1e26
diff --git a/Tests/test_imagepath.py b/Tests/test_imagepath.py
fc1e26
index beadff1..a0dee28 100644
fc1e26
--- a/Tests/test_imagepath.py
fc1e26
+++ b/Tests/test_imagepath.py
fc1e26
@@ -47,3 +47,8 @@ def test_path():
fc1e26
     assert_equal(list(p), [(0.0, 1.0)])
fc1e26
     p = ImagePath.Path(array.array("f", [0, 1]).tostring())
fc1e26
     assert_equal(list(p), [(0.0, 1.0)])
fc1e26
+
fc1e26
+def test_getbbox():
fc1e26
+    for coords in (0,1):
fc1e26
+        p = ImagePath.Path(coords)
fc1e26
+        assert_equal(p.getbbox(), (0.0, 0.0, 0.0, 0.0))
fc1e26
diff --git a/path.c b/path.c
fc1e26
index 871da93..059e738 100644
fc1e26
--- a/path.c
fc1e26
+++ b/path.c
fc1e26
@@ -57,7 +57,7 @@ alloc_array(Py_ssize_t count)
fc1e26
         PyErr_NoMemory();
fc1e26
         return NULL;
fc1e26
     }
fc1e26
-    xy = malloc(2 * count * sizeof(double) + 1);
fc1e26
+    xy = calloc(2 * count + 1, sizeof(double));
fc1e26
     if (!xy)
fc1e26
         PyErr_NoMemory();
fc1e26
     return xy;
fc1e26
@@ -336,18 +336,27 @@ path_getbbox(PyPathObject* self, PyObject* args)
fc1e26
 
fc1e26
     xy = self->xy;
fc1e26
 
fc1e26
-    x0 = x1 = xy[0];
fc1e26
-    y0 = y1 = xy[1];
fc1e26
-
fc1e26
-    for (i = 1; i < self->count; i++) {
fc1e26
-	if (xy[i+i] < x0)
fc1e26
-	    x0 = xy[i+i];
fc1e26
-	if (xy[i+i] > x1)
fc1e26
-	    x1 = xy[i+i];
fc1e26
-	if (xy[i+i+1] < y0)
fc1e26
-	    y0 = xy[i+i+1];
fc1e26
-	if (xy[i+i+1] > y1)
fc1e26
-	    y1 = xy[i+i+1];
fc1e26
+    if (self->count == 0) {
fc1e26
+        x0 = x1 = 0;
fc1e26
+        y0 = y1 = 0;
fc1e26
+    } else {
fc1e26
+        x0 = x1 = xy[0];
fc1e26
+        y0 = y1 = xy[1];
fc1e26
+
fc1e26
+        for (i = 1; i < self->count; i++) {
fc1e26
+            if (xy[i + i] < x0) {
fc1e26
+                x0 = xy[i + i];
fc1e26
+            }
fc1e26
+            if (xy[i + i] > x1) {
fc1e26
+                x1 = xy[i + i];
fc1e26
+            }
fc1e26
+            if (xy[i + i + 1] < y0) {
fc1e26
+                y0 = xy[i + i + 1];
fc1e26
+            }
fc1e26
+            if (xy[i + i + 1] > y1) {
fc1e26
+                y1 = xy[i + i + 1];
fc1e26
+            }
fc1e26
+        }
fc1e26
     }
fc1e26
 
fc1e26
     return Py_BuildValue("dddd", x0, y0, x1, y1);