summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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 */
}