summaryrefslogtreecommitdiffstats
path: root/libdimension
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2010-01-18 23:40:39 -0500
committerTavian Barnes <tavianator@gmail.com>2010-01-18 23:40:39 -0500
commit01775fe7c989415269bb8da1e63ddbf4874f3d50 (patch)
treedbcb779a66e67340a2a8a3ed024b2682e5ad2aff /libdimension
parentf20792e865f90665bba84c16e94cf4a3aa682a42 (diff)
downloaddimension-01775fe7c989415269bb8da1e63ddbf4874f3d50.tar.xz
Check for empty array in dmnsn_array_pop().
Diffstat (limited to 'libdimension')
-rw-r--r--libdimension/dimension/array.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/libdimension/dimension/array.h b/libdimension/dimension/array.h
index 0a2551b..4c086b7 100644
--- a/libdimension/dimension/array.h
+++ b/libdimension/dimension/array.h
@@ -139,6 +139,11 @@ DMNSN_INLINE void
dmnsn_array_pop(dmnsn_array *array, void *obj)
{
size_t size = dmnsn_array_size(array);
+ if (size <= 0) {
+ /* Range check failed */
+ dmnsn_error(DMNSN_SEVERITY_HIGH, "Array is empty.");
+ }
+
dmnsn_array_get(array, size - 1, obj); /* Copy the object */
dmnsn_array_resize(array, size - 1); /* Shrink the array */
}