Update of /cvsroot/refdb/refdb/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18016
Modified Files:
refdbxp.c
Log Message:
fixed memory allocation problems
Index: refdbxp.c
===================================================================
RCS file: /cvsroot/refdb/refdb/src/refdbxp.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -U2 -r1.7 -r1.8
--- refdbxp.c 19 Mar 2004 23:23:12 -0000 1.7
+++ refdbxp.c 20 Jun 2004 21:55:22 -0000 1.8
@@ -83,4 +83,5 @@
char typesep = '-'; /* separator for A,Q,Y etc suffix */
+
/* prototypes */
int handle_full_style(Liliment *ptr_first, Lilicit *ptr_first_cit);
@@ -222,4 +223,6 @@
/* loop over all \n-terminated lines of the input */
while ((result = fget_line(&linebuffer, &lb_len, start_tag, end_tag, infp)) != NULL) {
+/* fprintf(stderr, linebuffer); */
+
/* get sizes of linebuffer and outbuffer in sync if necessary */
if (lb_len > ob_len) {
@@ -341,6 +344,8 @@
fputs(result, stdout);
}
+
if (lb_len > LINE_SIZE) {
- new_linebuffer = (char*)realloc(linebuffer, LINE_SIZE);
+ lb_len = LINE_SIZE;
+ new_linebuffer = (char*)realloc(linebuffer, lb_len);
if (!new_linebuffer) {
delete_all_lilicit(&cit_sentinel);
@@ -355,4 +360,10 @@
}
}
+
+ if (uplinebuffer) { /* only used for SGML data, otherwise NULL */
+ free(uplinebuffer);
+ uplinebuffer = NULL;
+ }
+
linebuffer[0] = '\0';
}
@@ -399,5 +410,5 @@
cit_sentinel.cit = NULL;
- if (!ptr_first->eldata && !*(ptr_first->eldata)) {
+ if (!ptr_first || (!ptr_first->eldata && !*(ptr_first->eldata))) {
return 0; /* nothing to do */
}
@@ -421,4 +432,5 @@
for (token = strtok(ptr_first->eldata, "<"); token; token = strtok(NULL, "<")) {
+/* fprintf(stderr, "token:%s<<\n", token); */
if (!n_intype) {
strup(token);
@@ -773,5 +785,5 @@
char *start_cit;
char *end_cit;
- char *my_cit;
+ char *my_cit = NULL;
size_t len;
size_t total_len = 0;
@@ -798,5 +810,5 @@
if (result[len-1] == '\n') {
if (!n_have_cit) {
- /* now we need to check whether the curent line contains
+ /* now we need to check whether the current line contains
the start of an unfinished citation element. If so, we
need to loop until we find the matching end tag */
@@ -827,4 +839,5 @@
n_have_cit = 1;
}
+ my_cit = NULL;
}
}
@@ -885,4 +898,5 @@
}
}
+
return *linebuffer;
}
|