summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/common_io.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/common_io.c b/src/common_io.c
index f1319f8..5b35e07 100644
--- a/src/common_io.c
+++ b/src/common_io.c
@@ -64,10 +64,15 @@ delete_io_handle(struct pci_io_handle *handle)
}
}
- new = realloc(ios, sizeof(struct pci_io_handle) * (num_ios - 1));
- if (new)
- ios = new;
num_ios--;
+ if (num_ios) {
+ new = realloc(ios, sizeof(struct pci_io_handle) * num_ios);
+ if (new)
+ ios = new;
+ } else {
+ free(ios);
+ ios = NULL;
+ }
}
_pci_hidden void