*** a/src/backend/access/gist/gistutil.c
--- b/src/backend/access/gist/gistutil.c
***************
*** 526,536 **** gistpenalty(GISTSTATE *giststate, int attno,
--- 526,540 ----
  
  	if (giststate->penaltyFn[attno].fn_strict == FALSE ||
  		(isNullOrig == FALSE && isNullAdd == FALSE))
+ 	{
  		FunctionCall3Coll(&giststate->penaltyFn[attno],
  						  giststate->supportCollation[attno],
  						  PointerGetDatum(orig),
  						  PointerGetDatum(add),
  						  PointerGetDatum(&penalty));
+ 		if (penalty < 0.0)
+ 			penalty = 0.0;
+ 	}
  	else if (isNullOrig && isNullAdd)
  		penalty = 0.0;
  	else
