function: Check for invalid closure

In certain cases, it's possible that a GObject's dispose handler will try
to call into JS code during the shutdown GC. That ought to be stopped
with the check for _gjs_context_is_sweeping() in gjs_callback_closure(),
but not when the closure is already invalidated; in that case we can't
get to the GjsContext pointer, as it will have been nulled out in the
GjsClosure struct.

In that case, check first if we have an invalid closure (which is the
same as checking that the GjsContext pointer is not null.)

Closes #148.
11 jobs for 148-invalid-closure in 32 minutes and 43 seconds (queued for 4 seconds)
Status Job ID Name Coverage
  Source Check
passed #25423
cppcheck

00:01:05

passed #25424
cpplint

00:01:20

passed #25425
eslint

00:01:08

passed #25422
fedora

00:02:05

 
  Test
passed #25426
fedora_clang

00:04:47

 
  Thorough Tests
passed #25429
coverage

00:23:54

passed #25428
installed_tests

00:06:28

manual #25432
allowed to fail manual
no_graphics
passed #25427
no_profiler

00:02:07

passed #25430
sanitizer_gcc

00:10:50

manual #25431
allowed to fail manual
valgrind