Fix potential null pointer dereference in src/context.cpp