From 6cf8bb3136c42399ae075ea02997ce278335acae Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Mon, 7 Aug 2017 14:08:28 +0200 Subject: [PATCH] B OpenNebula seg faults when there are gaps in the history sequence (cherry picked from commit ea357cc58f88c634f08d848e369a4c4ae0f2ae42) --- src/vm/VirtualMachine.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/vm/VirtualMachine.cc b/src/vm/VirtualMachine.cc index 44ed421a48..15a176b480 100644 --- a/src/vm/VirtualMachine.cc +++ b/src/vm/VirtualMachine.cc @@ -2128,10 +2128,16 @@ int VirtualMachine::from_xml(const string &xml_str) if ( xpath(last_seq,"/VM/HISTORY_RECORDS/HISTORY/SEQ", -1) == 0 && last_seq != -1 ) { + history_records.resize(last_seq + 1); + + for (int i=0; i <= last_seq; ++i) + { + history_records[i] = 0; + } + history = new History(oid, last_seq); - history_records.resize(history->seq + 1); - history_records[history->seq] = history; + history_records[last_seq] = history; } // -------------------------------------------------------------------------