@@ -1073,9 +1073,14 @@ print_param_value(char *value, int len, int is_binary, int lineno, int nth)
10731073else
10741074{
10751075value_s = ecpg_alloc (ecpg_hex_enc_len (len )+ 1 ,lineno );
1076- ecpg_hex_encode (value ,len ,value_s );
1077- value_s [ecpg_hex_enc_len (len )]= '\0' ;
1078- malloced = true;
1076+ if (value_s != NULL )
1077+ {
1078+ ecpg_hex_encode (value ,len ,value_s );
1079+ value_s [ecpg_hex_enc_len (len )]= '\0' ;
1080+ malloced = true;
1081+ }
1082+ else
1083+ value_s = "no memory for logging of parameter" ;
10791084}
10801085
10811086ecpg_log ("ecpg_free_params on line %d: parameter %d = %s\n" ,
@@ -1134,7 +1139,7 @@ insert_tobeinserted(int position, int ph_len, struct statement *stmt, char *tobe
11341139ecpg_free (stmt -> command );
11351140stmt -> command = newcopy ;
11361141
1137- ecpg_free (( char * ) tobeinserted );
1142+ ecpg_free (tobeinserted );
11381143return true;
11391144}
11401145
@@ -1400,6 +1405,7 @@ ecpg_build_params(struct statement *stmt)
14001405ECPG_SQLSTATE_USING_CLAUSE_DOES_NOT_MATCH_PARAMETERS ,
14011406NULL );
14021407ecpg_free_params (stmt , false);
1408+ ecpg_free (tobeinserted );
14031409return false;
14041410}
14051411
@@ -1436,33 +1442,28 @@ ecpg_build_params(struct statement *stmt)
14361442}
14371443else
14381444{
1439- char * * paramvalues ;
1440- int * paramlengths ;
1441- int * paramformats ;
1442-
1443- if (!(paramvalues = (char * * )ecpg_realloc (stmt -> paramvalues ,sizeof (char * )* (stmt -> nparams + 1 ),stmt -> lineno )))
1445+ if (!(stmt -> paramvalues = (char * * )ecpg_realloc (stmt -> paramvalues ,sizeof (char * )* (stmt -> nparams + 1 ),stmt -> lineno )))
14441446{
14451447ecpg_free_params (stmt , false);
1448+ ecpg_free (tobeinserted );
14461449return false;
14471450}
1448- if (!(paramlengths = (int * )ecpg_realloc (stmt -> paramlengths ,sizeof (int )* (stmt -> nparams + 1 ),stmt -> lineno )))
1451+ stmt -> paramvalues [stmt -> nparams ]= tobeinserted ;
1452+
1453+ if (!(stmt -> paramlengths = (int * )ecpg_realloc (stmt -> paramlengths ,sizeof (int )* (stmt -> nparams + 1 ),stmt -> lineno )))
14491454{
14501455ecpg_free_params (stmt , false);
14511456return false;
14521457}
1453- if (!(paramformats = (int * )ecpg_realloc (stmt -> paramformats ,sizeof (int )* (stmt -> nparams + 1 ),stmt -> lineno )))
1458+ stmt -> paramlengths [stmt -> nparams ]= binary_length ;
1459+
1460+ if (!(stmt -> paramformats = (int * )ecpg_realloc (stmt -> paramformats ,sizeof (int )* (stmt -> nparams + 1 ),stmt -> lineno )))
14541461{
14551462ecpg_free_params (stmt , false);
14561463return false;
14571464}
1458-
1465+ stmt -> paramformats [ stmt -> nparams ] = ( binary_format ? 1 : 0 );
14591466stmt -> nparams ++ ;
1460- stmt -> paramvalues = paramvalues ;
1461- stmt -> paramlengths = paramlengths ;
1462- stmt -> paramformats = paramformats ;
1463- stmt -> paramvalues [stmt -> nparams - 1 ]= tobeinserted ;
1464- stmt -> paramlengths [stmt -> nparams - 1 ]= binary_length ;
1465- stmt -> paramformats [stmt -> nparams - 1 ]= (binary_format ?1 :0 );
14661467
14671468/* let's see if this was an old style placeholder */
14681469if (stmt -> command [position ]== '?' )