Avoid dereferencing NULL pointers.
This commit is contained in:
parent
97c69bdcba
commit
60641ca499
@ -26,7 +26,9 @@ void initialize_card(struct card *card) {
|
||||
}
|
||||
|
||||
void delete_card(struct card *card) {
|
||||
if (card) {
|
||||
delete_frame(card->frame);
|
||||
}
|
||||
free(card);
|
||||
|
||||
return;
|
||||
|
@ -51,7 +51,7 @@ void initialize_deck(struct deck *deck) {
|
||||
}
|
||||
|
||||
void delete_deck(struct deck *deck) {
|
||||
delete_stack(deck->stock);
|
||||
if (deck) {
|
||||
delete_stack(deck->waste_pile);
|
||||
|
||||
delete_stack(deck->foundation_0);
|
||||
@ -66,7 +66,7 @@ void delete_deck(struct deck *deck) {
|
||||
delete_stack(deck->maneuvre_4);
|
||||
delete_stack(deck->maneuvre_5);
|
||||
delete_stack(deck->maneuvre_6);
|
||||
|
||||
}
|
||||
free(deck);
|
||||
|
||||
return;
|
||||
|
@ -23,7 +23,9 @@ void initialize_frame(struct frame *frame) {
|
||||
}
|
||||
|
||||
void delete_frame(struct frame *frame) {
|
||||
if (frame) {
|
||||
delwin(frame->shape);
|
||||
}
|
||||
free(frame);
|
||||
|
||||
return;
|
||||
|
@ -29,7 +29,9 @@ void initialize_stack(struct stack *stack) {
|
||||
}
|
||||
|
||||
void delete_stack(struct stack *stack) {
|
||||
if (stack) {
|
||||
delete_card(stack->card);
|
||||
}
|
||||
free(stack);
|
||||
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user