projects
/
babeltrace.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix: missing free on error path
[babeltrace.git]
/
plugins
/
writer
/
writer.c
diff --git
a/plugins/writer/writer.c
b/plugins/writer/writer.c
index c9ec3479a8cb849541722288e2058796bf54b447..ad268ebf74aa6fc28c4615fb901ff9004031c89d 100644
(file)
--- a/
plugins/writer/writer.c
+++ b/
plugins/writer/writer.c
@@
-45,6
+45,8
@@
void destroy_writer_component_data(struct writer_component *writer_component)
g_hash_table_destroy(writer_component->stream_map);
g_hash_table_destroy(writer_component->stream_class_map);
g_hash_table_destroy(writer_component->trace_map);
g_hash_table_destroy(writer_component->stream_map);
g_hash_table_destroy(writer_component->stream_class_map);
g_hash_table_destroy(writer_component->trace_map);
+ g_string_free(writer_component->base_path, true);
+ g_string_free(writer_component->trace_name_base, true);
}
static
}
static
@@
-90,7
+92,12
@@
struct writer_component *create_writer_component(void)
writer_component->err = stderr;
writer_component->trace_id = 0;
writer_component->err = stderr;
writer_component->trace_id = 0;
- snprintf(writer_component->trace_name_base, NAME_MAX, "trace");
+ writer_component->trace_name_base = g_string_new("trace");
+ if (!writer_component->trace_name_base) {
+ g_free(writer_component);
+ writer_component = NULL;
+ goto end;
+ }
/*
* Reader to writer corresponding structures.
/*
* Reader to writer corresponding structures.
@@
-233,7
+240,11
@@
enum bt_component_status writer_component_init(
goto error;
}
goto error;
}
- strncpy(writer_component->base_path, path, PATH_MAX);
+ writer_component->base_path = g_string_new(path);
+ if (!writer_component) {
+ ret = BT_COMPONENT_STATUS_ERROR;
+ goto error;
+ }
ret = bt_component_set_destroy_cb(component,
destroy_writer_component);
ret = bt_component_set_destroy_cb(component,
destroy_writer_component);
@@
-256,6
+267,7
@@
end:
return ret;
error:
destroy_writer_component_data(writer_component);
return ret;
error:
destroy_writer_component_data(writer_component);
+ g_free(writer_component);
return ret;
}
return ret;
}
This page took
0.027267 seconds
and
4
git commands to generate.