aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErik Liodden <[email protected]>2017-12-10 01:05:48 +0100
committerErik Liodden <[email protected]>2017-12-10 01:05:48 +0100
commiteea60e4a591e62b21f26de1fa322f759bd5270b1 (patch)
tree166a83303100c556894662b8af4cc7a753d7b5a1
parent7f7d2dc352fa7ddebec8337ba4e53b7a1f3822fc (diff)
downloadalgdat-eea60e4a591e62b21f26de1fa322f759bd5270b1.tar.gz
negate check on stack_get
this should be the bad conditions, not the good ones.
-rw-r--r--stack.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/stack.c b/stack.c
index c72a6ca..ded2377 100644
--- a/stack.c
+++ b/stack.c
@@ -49,7 +49,7 @@ void stack_push(struct stack *s, void *elem_addr)
void stack_get(struct stack *s, void *elem_addr, int loc)
{
- if (s->log_length > 0 && loc < s->log_length && loc >= 0) {
+ if (s->log_length <= 0 || loc >= s->log_length || loc < 0) {
fprintf(stderr, "array out of bounds: size %d, index: %d\n",
s->log_length, loc);
exit(EXIT_FAILURE);