Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0cc0507

Browse files
author
Michael Meskes
committed
Hopefully fixing memory handling issues in ecpglib that Coverity found.
1 parent6e52209 commit0cc0507

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

‎src/interfaces/ecpg/ecpglib/execute.c

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,9 +1073,14 @@ print_param_value(char *value, int len, int is_binary, int lineno, int nth)
10731073
else
10741074
{
10751075
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";
10791084
}
10801085

10811086
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
11341139
ecpg_free(stmt->command);
11351140
stmt->command=newcopy;
11361141

1137-
ecpg_free((char*)tobeinserted);
1142+
ecpg_free(tobeinserted);
11381143
return true;
11391144
}
11401145

@@ -1400,6 +1405,7 @@ ecpg_build_params(struct statement *stmt)
14001405
ECPG_SQLSTATE_USING_CLAUSE_DOES_NOT_MATCH_PARAMETERS,
14011406
NULL);
14021407
ecpg_free_params(stmt, false);
1408+
ecpg_free(tobeinserted);
14031409
return false;
14041410
}
14051411

@@ -1436,33 +1442,28 @@ ecpg_build_params(struct statement *stmt)
14361442
}
14371443
else
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
{
14451447
ecpg_free_params(stmt, false);
1448+
ecpg_free(tobeinserted);
14461449
return 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
{
14501455
ecpg_free_params(stmt, false);
14511456
return 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
{
14551462
ecpg_free_params(stmt, false);
14561463
return false;
14571464
}
1458-
1465+
stmt->paramformats[stmt->nparams]= (binary_format ?1 :0);
14591466
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);
14661467

14671468
/* let's see if this was an old style placeholder */
14681469
if (stmt->command[position]=='?')

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp