diff --git a/task2/task2.c b/task2/task2.c index a0f908c..ca635db 100644 --- a/task2/task2.c +++ b/task2/task2.c @@ -120,6 +120,10 @@ int parse(char *s, STACK* stack) { int main(int argc, char **argv) { STACK* operands = init_stack(argc); + if (operands == NULL) { + fprintf(stderr, "Error creating operand stack.\n"); + return(2); + } int error; while(*++argv) { error = parse(*argv, operands); @@ -131,6 +135,7 @@ int main(int argc, char **argv) { int i; printf("Stack status:\n"); for (i = (operands -> cnt); i > 0; i--) printf("%f\n", pop(operands)); + destroy_stack(operands); return 0; }