Skip to content

Commit

Permalink
Fix some memory leaks, including one very serious one in the backend
Browse files Browse the repository at this point in the history
  • Loading branch information
Steve Harris committed Feb 11, 2011
1 parent 17a6e84 commit 9367486
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/backend/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -930,6 +930,7 @@ static unsigned char * handle_resolve_attr (fs_backend *be, fs_segment segment,
/* ASCII NUL is used to terminate strings on the wire */
if (resources[k].lex) {
strcpy((char *) record + 20, resources[k].lex);
free(resources[k].lex);
} else {
*(record + 20) = '\0';
}
Expand Down
7 changes: 4 additions & 3 deletions src/frontend/query.c
Original file line number Diff line number Diff line change
Expand Up @@ -847,13 +847,15 @@ int fs_query_process_pattern(fs_query *q, rasqal_graph_pattern *pattern, raptor_
fs_binding *old = q->bb[j];
q->bb[j] = fs_binding_apply_filters(q, j, q->bb[j], q->constraints[j]);
fs_binding_free(old);
raptor_free_sequence(q->constraints[j]);
q->constraints[j] = NULL;
}
} else {
if (q->constraints[j]) {
fs_binding *old = q->bb[j];
q->bb[j] = fs_binding_apply_filters(q, j, q->bb[j], q->constraints[j]);
fs_binding_free(old);
raptor_free_sequence(q->constraints[j]);
q->constraints[j] = NULL;
}
fs_binding_union(q, q->bb[first_in_union], q->bb[j]);
Expand Down Expand Up @@ -925,6 +927,7 @@ int fs_query_process_pattern(fs_query *q, rasqal_graph_pattern *pattern, raptor_
fs_binding *old = q->bb[j];
q->bb[j] = fs_binding_apply_filters(q, j, q->bb[j], q->constraints[j]);
fs_binding_free(old);
raptor_free_sequence(q->constraints[j]);
q->constraints[j] = NULL;
/* do the left join */
fs_binding *nb = fs_binding_join(q, q->bb[i], q->bb[j], FS_LEFT);
Expand Down Expand Up @@ -962,9 +965,6 @@ void fs_query_free(fs_query *q)
if (q->blocks) {
for (int i=0; i<FS_MAX_BLOCKS; i++) {
if (q->blocks[i].data) {
for (int j=0; j<q->blocks[i].length; j++) {
free(q->blocks[i].data[j]);
}
free(q->blocks[i].data);
}
}
Expand Down Expand Up @@ -1257,6 +1257,7 @@ static void graph_pattern_walk(fsp_link *link, rasqal_graph_pattern *pattern,
rasqal_triple *rt = rasqal_graph_pattern_get_triple(pattern, i);
if (!rt) break;
rasqal_triple *t = calloc(1, sizeof(rasqal_triple));
fs_query_add_freeable(q, t);
t->origin = model;
t->subject = rt->subject;
t->predicate = rt->predicate;
Expand Down
6 changes: 6 additions & 0 deletions src/frontend/results.c
Original file line number Diff line number Diff line change
Expand Up @@ -1440,6 +1440,9 @@ static void handle_construct(fs_query *q, const char *type, FILE *output)
st.predicate = slot_fill(q, trip->predicate, row);
st.object = slot_fill(q, trip->object, row);
raptor_serializer_serialize_statement(q->ser, &st);
raptor_free_term(st.subject);
raptor_free_term(st.predicate);
raptor_free_term(st.object);
}
}
}
Expand Down Expand Up @@ -1471,6 +1474,9 @@ static void handle_construct(fs_query *q, const char *type, FILE *output)
st.predicate = slot_fill(q, trip->predicate, row);
st.object = slot_fill(q, trip->object, row);
raptor_serializer_serialize_statement(q->ser, &st);
raptor_free_term(st.subject);
raptor_free_term(st.predicate);
raptor_free_term(st.object);
}
}
}
Expand Down

0 comments on commit 9367486

Please sign in to comment.