backport from trunk (rev #10011)

always free the DB result ( or else subsequent select queries will/might fail )