Skip to content

Commit 838f476

Browse files
committed
make sure null pointers are returned for some error cases.
1 parent 9d4f736 commit 838f476

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/json_value_module.F90

+5
Original file line numberDiff line numberDiff line change
@@ -2699,6 +2699,7 @@ subroutine json_get_parent(json,p,parent)
26992699
if (associated(p)) then
27002700
parent => p%parent
27012701
else
2702+
nullify(parent)
27022703
call json%throw_exception('Error in json_get_parent: '//&
27032704
'pointer is not associated.')
27042705
end if
@@ -2724,6 +2725,7 @@ subroutine json_get_next(json,p,next)
27242725
if (associated(p)) then
27252726
next => p%next
27262727
else
2728+
nullify(next)
27272729
call json%throw_exception('Error in json_get_next: '//&
27282730
'pointer is not associated.')
27292731
end if
@@ -2749,6 +2751,7 @@ subroutine json_get_previous(json,p,previous)
27492751
if (associated(p)) then
27502752
previous => p%previous
27512753
else
2754+
nullify(previous)
27522755
call json%throw_exception('Error in json_get_previous: '//&
27532756
'pointer is not associated.')
27542757
end if
@@ -2775,6 +2778,7 @@ subroutine json_get_tail(json,p,tail)
27752778
if (associated(p)) then
27762779
tail => p%tail
27772780
else
2781+
nullify(tail)
27782782
call json%throw_exception('Error in json_get_tail: '//&
27792783
'pointer is not associated.')
27802784
end if
@@ -2846,6 +2850,7 @@ subroutine json_value_get_child(json, p, child)
28462850
if (associated(p)) then
28472851
child => p%children
28482852
else
2853+
nullify(child)
28492854
call json%throw_exception('Error in json_value_get_child: '//&
28502855
'pointer is not associated.')
28512856
end if

0 commit comments

Comments
 (0)