libfoundation: Fixed bug in array creation from object list.

Cherry-picked from commit 06ab0a944f44.
Merge pull request #1431 from peter-b/misc-arraycreate

libfoundation: Fixed bug in array creation from object list.