Fix memory leak

This commit is contained in:
Inex Code 2020-03-07 14:24:02 +03:00
parent b7c0451cd2
commit eca8a60141
1 changed files with 5 additions and 0 deletions

View File

@ -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;
}