[ I think you may have meant to CC me not Alexey K. I'm probably the person responsible :D. ]
Indeed, I think the simplest fix is to make plperl_ref_from_pg_array() return an "empty" array in that case. The attached fixes the valgrind warning for me. (cassert enabled build on master).
Looks good to me, thank you. Judging from the size in the error message it’s likely the
info->nelems[0] = items
line that caused this issue. The patch fixes it at first glance, although I have yet to make my valgrind setup on OS X working to check this for real :-)