#vulnerable code 
                             public static Object emit(HttpExchange x) {
		int event = U.num(x.data("event"));

		TagContext ctx = x.session(SESSION_CTX, null);

		// if the context has been lost, reload the page
		if (ctx == null) {
			return changes(x, PAGE_RELOAD);
		}

		Cmd cmd = ctx.getEventCmd(event);

		if (cmd != null) {
			Map<Integer, Object> inp = Pages.inputs(x);
			ctx.emitValues(inp);
		} else {
			U.warn("Invalid event!", "event", event);
		}

		Object page = U.newInstance(currentPage(x));
		Pages.load(x, page);

		callCmdHandler(x, page, cmd);

		ctx = Tags.context();
		x.sessionSet(Pages.SESSION_CTX, ctx);

		Object content = Pages.contentOf(x, page);

		if (content == null || content instanceof HttpExchange) {
			return content;
		}

		String html = PageRenderer.get().toHTML(ctx, content, x);

		Pages.store(x, page);

		return changes(x, html);
	} 
                            #location 23 
                            #vulnerability type NULL_DEREFERENCE
#fixed code
                             public static Object emit(HttpExchange x) {
		int event = U.num(x.data("event"));

		TagContext ctx = x.session(SESSION_CTX, null);

		// if the context has been lost, reload the page
		if (ctx == null) {
			return changes(x, PAGE_RELOAD);
		}

		Cmd cmd = ctx.getEventCmd(event);

		if (cmd != null) {
			Map<Integer, Object> inp = Pages.inputs(x);
			ctx.emitValues(inp);
		} else {
			U.warn("Invalid event!", "event", event);
		}

		Object page = U.newInstance(currentPage(x));
		Pages.load(x, page);

		if (cmd != null) {
			callCmdHandler(x, page, cmd);
		}

		ctx = Tags.context();
		x.sessionSet(Pages.SESSION_CTX, ctx);

		Object content = Pages.contentOf(x, page);

		if (content == null || content instanceof HttpExchange) {
			return content;
		}

		String html = PageRenderer.get().toHTML(ctx, content, x);

		Pages.store(x, page);

		return changes(x, html);
	}