vpnor: Fix SEGV fault in vpnor
Table object may throw error hence initialize table pointer to null so
that vpnor_free() doesn't free the junk pointer.
In vpnor_free() do not free table pointer if its null.
Added testcase to make sure the issue is fixed.
```
PASS: vpnor/test/toc_missing_file_reset
```
Change-Id: Ic6f4a7d163cf786d71b810190ab6ede0cd3a0717
Signed-off-by: Ninad Palsule <ninad@linux.ibm.com>
diff --git a/vpnor/backend.cpp b/vpnor/backend.cpp
index 3866c57..d081b13 100644
--- a/vpnor/backend.cpp
+++ b/vpnor/backend.cpp
@@ -85,6 +85,9 @@
try
{
priv->vpnor = new vpnor_partition_table;
+ // Table object may throw error hence initialize table pointer
+ // to null so that no one try to free the junk pointer.
+ priv->vpnor->table = NULL;
priv->vpnor->table =
new openpower::virtual_pnor::partition::Table(backend);
}