db_flatstore: free result before returning null on no more pkg
- partial allocation when doing an incomplete new connection
(cherry picked from commit 74743d6ef3bf74c1226ba5a1b6bebfbe19b06b93)
(cherry picked from commit 386ef2f61d18966ceb70916869389f2690e0a6ef)