gmain: Fix next_source refcounting in g_source_iter_next

Cole Robinson requested to merge crobinso/glib:iter-refcount-fix into master

The g_source_unref_internal call can drop the context lock, during which next_source can be free'd behind our backs, after which things can get crashy. Move the next_source ref earlier to avoid this.

Fixes: #2031 (closed)

Signed-off-by: Cole Robinson

Merge request reports