@@ -1073,9 +1073,14 @@ print_param_value(char *value, int len, int is_binary, int lineno, int nth)
1073
1073
else
1074
1074
{
1075
1075
value_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" ;
1079
1084
}
1080
1085
1081
1086
ecpg_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
1134
1139
ecpg_free (stmt -> command );
1135
1140
stmt -> command = newcopy ;
1136
1141
1137
- ecpg_free (( char * ) tobeinserted );
1142
+ ecpg_free (tobeinserted );
1138
1143
return true;
1139
1144
}
1140
1145
@@ -1400,6 +1405,7 @@ ecpg_build_params(struct statement *stmt)
1400
1405
ECPG_SQLSTATE_USING_CLAUSE_DOES_NOT_MATCH_PARAMETERS ,
1401
1406
NULL );
1402
1407
ecpg_free_params (stmt , false);
1408
+ ecpg_free (tobeinserted );
1403
1409
return false;
1404
1410
}
1405
1411
@@ -1436,33 +1442,28 @@ ecpg_build_params(struct statement *stmt)
1436
1442
}
1437
1443
else
1438
1444
{
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 )))
1444
1446
{
1445
1447
ecpg_free_params (stmt , false);
1448
+ ecpg_free (tobeinserted );
1446
1449
return false;
1447
1450
}
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 )))
1449
1454
{
1450
1455
ecpg_free_params (stmt , false);
1451
1456
return false;
1452
1457
}
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 )))
1454
1461
{
1455
1462
ecpg_free_params (stmt , false);
1456
1463
return false;
1457
1464
}
1458
-
1465
+ stmt -> paramformats [ stmt -> nparams ] = ( binary_format ? 1 : 0 );
1459
1466
stmt -> 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 );
1466
1467
1467
1468
/* let's see if this was an old style placeholder */
1468
1469
if (stmt -> command [position ] == '?' )
0 commit comments