Hi Alexander!
 >How this function could handle this case?
 >
 >list1: (NULL)
 >list2: whatever containing NULL
 >
 >The outer loop will just quit after iterating the only element of
 >list1 without even iterating list2.
Thanks for the case!
Patches with the fix are attached to email.
-- 
With best regards,
Dmitry Koval
Postgres Professional: http://postgrespro.com