Browse Source

Fix various null pointer accesses

In procedure was a bug regarding the test of the position of the
founded key/value pair. Because of this bug, a segmentation fault
happened when deallocationg the key/value pair. This is fixed now by
checking both neighbor entries for null
pull/1/head
T. Meissner 9 years ago
parent
commit
f453a6138d
1 changed files with 8 additions and 7 deletions
  1. +8
    -7
      sim/DictP.vhd

+ 8
- 7
sim/DictP.vhd View File

@ -57,7 +57,7 @@ package body DictP is
v_entry.key := new string'(key);
v_entry.data := new std_logic_vector'(data);
v_entry.last_entry := v_head;
v_entry.next_entry := v_entry;
v_entry.next_entry := null;
v_head := v_entry;
v_head.last_entry.next_entry := v_head;
else
@ -65,7 +65,7 @@ package body DictP is
v_head.key := new string'(key);
v_head.data := new std_logic_vector'(data);
v_head.last_entry := null;
v_head.next_entry := v_entry;
v_head.next_entry := null;
end if;
if (v_logging) then
report t_dict'instance_name & ": Add key " & key & " with data 0x" & to_hstring(data);
@ -98,14 +98,15 @@ package body DictP is
begin
if (v_entry /= null) then
-- remove head entry
if(v_entry.next_entry = null) then
if(v_entry.next_entry = null and v_entry.last_entry /= null) then
v_entry.last_entry.next_entry := null;
v_head := v_entry.last_entry;
v_head := v_entry.last_entry;
-- remove start entry
elsif(v_entry.last_entry = null) then
elsif(v_entry.next_entry /= null and v_entry.last_entry = null) then
v_entry.next_entry.last_entry := null;
-- remove entry between
else
v_entry.next_entry.last_entry := v_entry.last_entry;
-- remove from between
elsif(v_entry.next_entry /= null and v_entry.last_entry /= null) then
v_entry.last_entry.next_entry := v_entry.next_entry;
v_entry.next_entry.last_entry := v_entry.last_entry;
end if;


Loading…
Cancel
Save