88 *
99 *
1010 * IDENTIFICATION
11- * $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.148 2005/08/12 18:23:54 tgl Exp $
11+ * $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.149 2005/08/25 01:30:06 momjian Exp $
1212 *
1313 *-------------------------------------------------------------------------
1414 */
@@ -1892,7 +1892,7 @@ timestamp_mi(PG_FUNCTION_ARGS)
18921892{
18931893Timestamp dt1 = PG_GETARG_TIMESTAMP (0 );
18941894Timestamp dt2 = PG_GETARG_TIMESTAMP (1 );
1895- Interval * result ;
1895+ Interval * result , * result2 ;
18961896
18971897result = (Interval * )palloc (sizeof (Interval ));
18981898
@@ -1914,9 +1914,10 @@ timestamp_mi(PG_FUNCTION_ARGS)
19141914result -> month = 0 ;
19151915result -> day = 0 ;
19161916
1917- result = DatumGetIntervalP (DirectFunctionCall1 (interval_justify_hours ,
1917+ result2 = DatumGetIntervalP (DirectFunctionCall1 (interval_justify_hours ,
19181918IntervalPGetDatum (result )));
1919- PG_RETURN_INTERVAL_P (result );
1919+ pfree (result );
1920+ PG_RETURN_INTERVAL_P (result2 );
19201921}
19211922
19221923/*interval_justify_hours()
@@ -2263,7 +2264,7 @@ interval_mul(PG_FUNCTION_ARGS)
22632264Interval * span = PG_GETARG_INTERVAL_P (0 );
22642265float8 factor = PG_GETARG_FLOAT8 (1 );
22652266double month_remainder ,day_remainder ;
2266- Interval * result ;
2267+ Interval * result , * result2 ;
22672268
22682269result = (Interval * )palloc (sizeof (Interval ));
22692270
@@ -2289,9 +2290,10 @@ interval_mul(PG_FUNCTION_ARGS)
22892290day_remainder * SECS_PER_DAY );
22902291#endif
22912292
2292- result = DatumGetIntervalP (DirectFunctionCall1 (interval_justify_hours ,
2293+ result2 = DatumGetIntervalP (DirectFunctionCall1 (interval_justify_hours ,
22932294IntervalPGetDatum (result )));
2294- PG_RETURN_INTERVAL_P (result );
2295+ pfree (result );
2296+ PG_RETURN_INTERVAL_P (result2 );
22952297}
22962298
22972299Datum
@@ -2310,7 +2312,7 @@ interval_div(PG_FUNCTION_ARGS)
23102312Interval * span = PG_GETARG_INTERVAL_P (0 );
23112313float8 factor = PG_GETARG_FLOAT8 (1 );
23122314double month_remainder ,day_remainder ;
2313- Interval * result ;
2315+ Interval * result , * result2 ;
23142316
23152317result = (Interval * )palloc (sizeof (Interval ));
23162318
@@ -2341,9 +2343,10 @@ interval_div(PG_FUNCTION_ARGS)
23412343result -> time = JROUND (result -> time );
23422344#endif
23432345
2344- result = DatumGetIntervalP (DirectFunctionCall1 (interval_justify_hours ,
2346+ result2 = DatumGetIntervalP (DirectFunctionCall1 (interval_justify_hours ,
23452347IntervalPGetDatum (result )));
2346- PG_RETURN_INTERVAL_P (result );
2348+ pfree (result );
2349+ PG_RETURN_INTERVAL_P (result2 );
23472350}
23482351
23492352/*