1
- /* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.49 2006/06/25 09:38:39 meskes Exp $ */
1
+ /* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.50 2006/06/26 09:20:09 meskes Exp $ */
2
2
3
3
/*
4
4
* The aim is to get a simpler inteface to the database routines.
@@ -875,27 +875,27 @@ ECPGstore_input(const int lineno, const bool force_indicator, const struct varia
875
875
case ECPGt_numeric :
876
876
{
877
877
char * str = NULL ;
878
- int slen ;
878
+ int slen ;
879
879
numeric * nval = PGTYPESnumeric_new ();
880
880
881
- if (!nval )
882
- return false;
883
-
884
881
if (var -> arrsize > 1 )
885
882
{
886
883
for (element = 0 ; element < var -> arrsize ; element ++ , nval = PGTYPESnumeric_new ())
887
884
{
885
+ if (!nval )
886
+ return false;
887
+
888
888
if (var -> type == ECPGt_numeric )
889
889
PGTYPESnumeric_copy ((numeric * ) ((var + var -> offset * element )-> value ), nval );
890
890
else
891
891
PGTYPESnumeric_from_decimal ((decimal * ) ((var + var -> offset * element )-> value ), nval );
892
892
893
893
str = PGTYPESnumeric_to_asc (nval , nval -> dscale );
894
894
slen = strlen (str );
895
+ PGTYPESnumeric_free (nval );
895
896
896
897
if (!(mallocedval = ECPGrealloc (mallocedval , strlen (mallocedval ) + slen + sizeof ("array [] " ), lineno )))
897
898
{
898
- PGTYPESnumeric_free (nval );
899
899
ECPGfree (str );
900
900
return false;
901
901
}
@@ -906,32 +906,32 @@ ECPGstore_input(const int lineno, const bool force_indicator, const struct varia
906
906
strncpy (mallocedval + strlen (mallocedval ), str , slen + 1 );
907
907
strcpy (mallocedval + strlen (mallocedval ), "," );
908
908
ECPGfree (str );
909
- PGTYPESnumeric_free (nval );
910
909
}
911
910
strcpy (mallocedval + strlen (mallocedval ) - 1 , "]" );
912
911
}
913
912
else
914
913
{
914
+ if (!nval )
915
+ return false;
916
+
915
917
if (var -> type == ECPGt_numeric )
916
918
PGTYPESnumeric_copy ((numeric * ) (var -> value ), nval );
917
919
else
918
920
PGTYPESnumeric_from_decimal ((decimal * ) (var -> value ), nval );
919
921
920
922
str = PGTYPESnumeric_to_asc (nval , nval -> dscale );
921
-
922
923
slen = strlen (str );
924
+ PGTYPESnumeric_free (nval );
923
925
924
926
if (!(mallocedval = ECPGalloc (slen + 1 , lineno )))
925
927
{
926
- PGTYPESnumeric_free (nval );
927
928
free (str );
928
929
return false;
929
930
}
930
931
931
932
strncpy (mallocedval , str , slen );
932
933
mallocedval [slen ] = '\0' ;
933
934
ECPGfree (str );
934
- PGTYPESnumeric_free (nval );
935
935
}
936
936
937
937
* tobeinserted_p = mallocedval ;
0 commit comments