diff --git a/stack.c b/stack.c
index 0555575e7f5742c12a0d42ed1a4971e35d8ba9db..a2b1c5243607beb7486b8f7aed585d354c4a1c91 100644
--- a/stack.c
+++ b/stack.c
@@ -1,4 +1,3 @@
-#include <stdio.h>
 #include <stdlib.h>
 
 #define DEFAULT_CAPACITY 4
@@ -18,6 +17,11 @@ void stack_destroy(stack *s) {
 
 void stack_push(stack *s, int value)
 {
+    if (s->top == s->capacity-1)
+    {
+        assert(s->data = realloc(s->capacity * 2 * sizeof(int)));
+    }
+
     s->top++;
     s->data[s->top] = value;
 }