Skip to content

Commit 301163a

Browse files
committed
memory leak
1 parent cd914ba commit 301163a

File tree

2 files changed

+50
-8
lines changed

2 files changed

+50
-8
lines changed

informix_auditing/audit_util.c

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,19 @@ mi_string *do_castl(MI_CONNECTION *conn, MI_DATUM *datum,
6868
printf("-- typeName=%s --",srcType);
6969
if ((strcmp("blob", srcType) == 0) || (strcmp("clob", srcType) == 0) || (strcmp("text", srcType) == 0) || (strcmp("byte", srcType) == 0)) {
7070
printf("skiping data read\n");
71+
mi_free(dsc);
72+
mi_free(srcType);
7173
return("unsupportedtype");
7274
}
7375
else{
7476
if (strcmp("date", srcType) == 0) {
77+
mi_free(dsc);
78+
mi_free(srcType);
7579
return (mi_date_to_string((mi_date *)datum));
7680
}
7781
if (strcmp("datetime", srcType) == 0) {
82+
mi_free(dsc);
83+
mi_free(srcType);
7884
return (mi_datetime_to_string((mi_datetime *)datum));
7985
}
8086
if ((strcmp("integer", srcType) == 0) ||
@@ -122,7 +128,11 @@ mi_string *do_castl(MI_CONNECTION *conn, MI_DATUM *datum,
122128
mi_routine_end(conn, fn);
123129
//return mi_type_typename(mi_type_typedesc(conn, my_type_id));
124130
}
125-
131+
mi_free(fp);
132+
mi_free(dsc);
133+
mi_free(srcType);
134+
mi_free(typeid);
135+
mi_free(tdesc);
126136
return(pbuf);
127137
}
128138
/*--------------------------------------------------------------*/
@@ -206,6 +216,15 @@ mi_string *doInsertCN()
206216
}
207217
printf("\"DBNAME-TABLENAME-operation-TIME\": \"%s-%s-INSERT-%s-Completed\" \n",pdbname,tabname,cdatetime);
208218
free(cdatetime);
219+
mi_free(row);
220+
mi_free(tid);
221+
mi_free(lvarTid);
222+
mi_free(td);
223+
mi_free(rd);
224+
mi_free(ptabname);
225+
mi_free(pcolname);
226+
mi_free(pcast);
227+
mi_free(pdbname);
209228
return(buffer);
210229
}
211230
/*--------------------------------------------------------------*/
@@ -251,7 +270,7 @@ mi_string *doSelectCN()
251270
for (i = 0; i < colCount; i++) {
252271
/* get column name and type id */
253272
pcolname = mi_column_name(rd, i);
254-
DPRINTF("logger", 90, ("insert: colname: (0x%x) [%s]", pcolname, pcolname));
273+
DPRINTF("logger", 90, ("insert: colname: (0x%x) [%s]", pcolname, pcolname));
255274
tid = mi_column_type_id(rd, i);
256275
switch(mi_value(row, i, &datum, &collen)) {
257276
/* we should do this test */
@@ -324,7 +343,7 @@ mi_string *doDeleteCN()
324343
for (i = 0; i < colCount; i++) {
325344
/* get column name and type id */
326345
pcolname = mi_column_name(rd, i);
327-
DPRINTF("logger", 90, ("delete: colname: (0x%x) [%s]", pcolname, pcolname));
346+
DPRINTF("logger", 90, ("delete: colname: (0x%x) [%s]", pcolname, pcolname));
328347
tid = mi_column_type_id(rd, i);
329348
switch(mi_value(row, i, &datum, &collen)) {
330349
/* we should do this test */
@@ -364,7 +383,16 @@ DPRINTF("logger", 90, ("delete: colname: (0x%x) [%s]", pcolname, pcolname));
364383
sprintf(&buffer[posi], "}, \n \"uniquedatatype\" : \"false\" \n }");
365384
}
366385
printf("\"DBNAME-TABLENAME-operation-TIME\": \"%s-%s-DELETE-%s-Completed\" \n ", pdbname,ptabname,cdatetime);
367-
free(cdatetime);
386+
free(cdatetime);
387+
mi_free(row);
388+
mi_free(tid);
389+
mi_free(lvarTid);
390+
mi_free(td);
391+
mi_free(rd);
392+
mi_free(ptabname);
393+
mi_free(pcolname);
394+
mi_free(pcast);
395+
mi_free(pdbname);
368396
return(buffer);
369397
}
370398
/*--------------------------------------------------------------*/
@@ -481,6 +509,19 @@ mi_string *doUpdateCN()
481509
DPRINTF("logger", 90, ("Exiting doUpdateCN()"));
482510
printf("\"DBNAME-TABLENAME-operation-TIME\": \"%s-%s-UPDATE-%s-Completed\" \n ", pdbname,ptabname,cdatetime);
483511
free(cdatetime);
512+
mi_free(oldRow);
513+
mi_free(newRow);
514+
mi_free(tid);
515+
mi_free(lvarTid);
516+
mi_free(td);
517+
mi_free(rdOld);
518+
mi_free(rdNew);
519+
mi_free(ptabname);
520+
mi_free(poldcolname);
521+
mi_free(pnewcolname);
522+
mi_free(pcast);
523+
mi_free(pcast2);
524+
mi_free(pdbname);
484525
return(buffer);
485526
}
486527
/*--------------------------------------------------------------*/

informix_auditing/auditing2.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ MI_CALLBACK_STATUS MI_PROC_CALLBACK
185185
}
186186
/* write the record out */
187187
if (pcur == NULL) {
188-
DPRINTF("logger", 80, ("cbfunc(): pcur is null"));
188+
DPRINTF("logger", 80, ("cbfunc(): pcur is null"));
189189
} else {
190190
char filetime_buffer[30];
191191
struct timeval file_tv;
@@ -195,11 +195,11 @@ DPRINTF("logger", 80, ("cbfunc(): pcur is null"));
195195
strftime(filetime_buffer,30,"%m-%d-%Y_%T.",localtime(&file_curtime));
196196
printf("%s%ld\n",filetime_buffer,file_tv.tv_usec);
197197
sprintf(buffer, "%s%d_%d_%s%ld.json", LOGGERFILEPREFIX,
198-
pmem->sessionId, pcur->seq,filetime_buffer,file_tv.tv_usec);
199-
DPRINTF("logger", 80, ("cbfunc(): about to open file %s", buffer));
198+
pmem->sessionId, pcur->seq,filetime_buffer,file_tv.tv_usec);
199+
DPRINTF("logger", 80, ("cbfunc(): about to open file %s", buffer));
200200
fd = mi_file_open(buffer, O_WRONLY | O_APPEND | O_CREAT, 0644);
201201
if (pcur->json == NULL) {
202-
DPRINTF("logger", 80, ("cbfunc(): pcur->json is null"));
202+
DPRINTF("logger", 80, ("cbfunc(): pcur->json is null"));
203203
} else {
204204
ret = mi_file_write(fd, pcur->json, strlen(pcur->json));
205205
int res=posttopic(pcur->json, "http://ifxpg-migrator.topcoder-dev.com/fileevents");
@@ -243,6 +243,7 @@ DPRINTF("logger", 80, ("cbfunc(): pcur->json is null"));
243243
DPRINTF("logger", 80, (buffer));
244244
}
245245
pmem->gothandle = 0;
246+
mi_free(pmem);
246247
DPRINTF("logger", 80, ("Exiting cbfunc()"));
247248
return(MI_CB_CONTINUE);
248249
}

0 commit comments

Comments
 (0)