I have this code, which uses OCIlib:
int HoleInstrumentenDiffListeDB(GTree *tree)
{
OCI_Connection* cn;
OCI_Statement* st;
OCI_Resultset* rs;
if (!OCI_Initialize(err_handler, NULL, OCI_ENV_DEFAULT))
return EXIT_FAILURE;
char query[500];
query[0] ='\0';
cn = OCI_ConnectionCreate( "db", "user", "pass", OCI_SESSION_DEFAULT);
st = OCI_StatementCreate(cn);
strcat(query, "SELECT...");
OCI_ExecuteStmt(st, query);
rs = OCI_GetResultset(st);
int i = 1;
int j = 0;
char *symbolp;
while (OCI_FetchNext(rs)){
const char * symbolp = OCI_GetString(rs,2);
switch ( * OCI_GetString(rs,3))
{
case 'N':
insertQot(tree, symbolp, OCI_GetInt(rs, 1) );
printf("new \n");
break;
case 'U':
insertQot(tree, symbolp, OCI_GetInt(rs, 1) );
printf("upd \n");
break;
case 'D':
deleteQot(tree, symbolp);
printf("del \n");
break;
}
}
OCI_Cleanup();
return 1;
}
The connection is made, the select seems to work. But while checking it with valgrind I'm getting a lot of errorrs. Here few of them:
==21085== Source and destination overlap in memcpy(0x742dc80, 0x742dc80, 1)
==21085== at 0x4A24F66: _intel_fast_memcpy (mc_replace_strmem.c:894)
==21085== by 0x562E6D7: kpufprow (in /opt/oracle/product/10.2/lib/libclntsh.so.10.1)
==21085== by 0x562BFDE: kpufch0 (in /opt/oracle/product/10.2/lib/libclntsh.so.10.1)
==21085== by 0x562ACB6: kpufch (in /opt/oracle/product/10.2/lib/libclntsh.so.10.1)
==21085== by 0x5520A2F: OCIStmtFetch2 (in /opt/oracle/product/10.2/lib/libclntsh.so.10.1)
==21085== by 0x4CDAF6E: OCI_FetchData (resultset.c:506)
==21085== by 0x4CDB405: OCI_FetchNext (resultset.c:1117)
==21085== by 0x401B95: HoleInstrumentenDiffListeDB (unzipper_m.c:221)
==21085== by 0x402AA9: main (unzipper_m.c:691)
==21085== Conditional jump or move depends on uninitialised value(s)
==21085== at 0x5EC79DF: slpmloclfv (in /opt/oracle/product/10.2/lib/libclntsh.so.10.1)
==21085== by 0x5EC771E: slpmloc (in /opt/oracle/product/10.2/lib/libclntsh.so.10.1)
==21085== by 0x5EC4C44: lpmloadpkg (in /opt/oracle/product/10.2/lib/libclntsh.so.10.1)
==21085== by 0x5EAAA8E: lfvLoadPkg (in /opt/oracle/product/10.2/lib/libclntsh.so.10.1)
==21085== by 0x5EAA719: lfvSetShlMode (in /opt/oracle/product/10.2/lib/libclntsh.so.10.1)
==21085== by 0x5EAA518: lfvini1 (in /opt/oracle/product/10.2/lib/libclntsh.so.10.1)
==21085== by 0x5EAA234: lfvinit (in /opt/oracle/product/10.2/lib/libclntsh.so.10.1)
==21085== by 0x5ACD1C9: kpummpin (in /opt/oracle/product/10.2/lib/libclntsh.so.10.1)
==21085== by 0x547EED8: kpuenvcr (in /opt/oracle/product/10.2/lib/libclntsh.so.10.1)
==21085== by 0x551FCD5: OCIEnvCreate (in /opt/oracle/product/10.2/lib/libclntsh.so.10.1)
==21085== by 0x4CE311B: OCI_Initialize (library.c:1140)
==21085== by 0x401942: HoleInstrumentenDiffListeDB (unzipper_m.c:207)
==21085== Use of uninitialised value of size 8
==21085== at 0x56DFE05: ztceadecbk (in /opt/oracle/product/10.2/lib/libclntsh.so.10.1)
==21085== by 0x56DC6BC: ztceb_decblk (in /opt/oracle/product/10.2/lib/libclntsh.so.10.1)
==21085== by 0x56DC3BE: ztcebf (in /opt/oracle/product/10.2/lib/libclntsh.so.10.1)
==21085== by 0x56DBB8A: ztcef (in /opt/oracle/product/10.2/lib/libclntsh.so.10.1)
==21085== by 0x56DBC6E: ztcedec (in /opt/oracle/product/10.2/lib/libclntsh.so.10.1)
==21085== by 0x57341A3: ztvo5ed (in /opt/oracle/product/10.2/lib/libclntsh.so.10.1)
==21085== by 0x5734FA5: ztvo5ver (in /opt/oracle/product/10.2/lib/libclntsh.so.10.1)
==21085== by 0x54C899D: kpu8lgn (in /opt/oracle/product/10.2/lib/libclntsh.so.10.1)
==21085== by 0x54C649C: kpuauthxa (in /opt/oracle/product/10.2/lib/libclntsh.so.10.1)
==21085== by 0x54C5EA5: kpuauth (in /opt/oracle/product/10.2/lib/libclntsh.so.10.1)
==21085== by 0x551FF1A: OCISessionBegin (in /opt/oracle/product/10.2/lib/libclntsh.so.10.1)
==21085== by 0x4CD45EA: OCI_ConnectionLogon (connection.c:598)
Can I improve my code? If not - how safe is it to leave it like it is ?