diff --git a/src/pl/plpgsql/src/pl_handler.c b/src/pl/plpgsql/src/pl_handler.c
index b4854ef6f0bcd6c2b9ddabd2c05fe551073be242..36868fb273738fa20067470a4d7ef729f6457a04 100644
--- a/src/pl/plpgsql/src/pl_handler.c
+++ b/src/pl/plpgsql/src/pl_handler.c
@@ -110,6 +110,8 @@ plpgsql_extra_checks_check_hook(char **newvalue, void **extra, GucSource source)
 	}
 
 	myextra = (int *) malloc(sizeof(int));
+	if (!myextra)
+		return false;
 	*myextra = extrachecks;
 	*extra = (void *) myextra;