From ac237a888cbd2ffe8446adc8a51482e603ca3765 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 14 Apr 2019 11:11:24 +0200 Subject: Fix Windows cross-library malloc/free errors --- src/lib.c | 11 ++++++----- src/node.c | 6 ++++-- src/state.c | 7 +++++-- 3 files changed, 15 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/lib.c b/src/lib.c index bd7233b..68eff47 100644 --- a/src/lib.c +++ b/src/lib.c @@ -40,7 +40,8 @@ lilv_lib_open(LilvWorld* world, } const char* const lib_uri = lilv_node_as_uri(uri); - char* const lib_path = lilv_file_uri_parse(lib_uri, NULL); + char* const lib_path = (char*)serd_file_uri_parse( + (const uint8_t*)lib_uri, NULL); if (!lib_path) { return NULL; } @@ -49,7 +50,7 @@ lilv_lib_open(LilvWorld* world, void* lib = dlopen(lib_path, RTLD_NOW); if (!lib) { LILV_ERRORF("Failed to open library %s (%s)\n", lib_path, dlerror()); - lilv_free(lib_path); + serd_free(lib_path); return NULL; } @@ -65,17 +66,17 @@ lilv_lib_open(LilvWorld* world, if (!desc) { LILV_ERRORF("Call to %s:lv2_lib_descriptor failed\n", lib_path); dlclose(lib); - lilv_free(lib_path); + serd_free(lib_path); return NULL; } } else if (!df) { LILV_ERRORF("No `lv2_descriptor' or `lv2_lib_descriptor' in %s\n", lib_path); dlclose(lib); - lilv_free(lib_path); + serd_free(lib_path); return NULL; } - lilv_free(lib_path); + serd_free(lib_path); LilvLib* llib = (LilvLib*)malloc(sizeof(LilvLib)); llib->world = world; diff --git a/src/node.c b/src/node.c index 7dd6551..95f6a8c 100644 --- a/src/node.c +++ b/src/node.c @@ -283,11 +283,13 @@ lilv_node_get_turtle_token(const LilvNode* value) break; case LILV_VALUE_INT: node = serd_node_new_integer(value->val.int_val); - result = (char*)node.buf; + result = lilv_strdup((char*)node.buf); + serd_node_free(&node); break; case LILV_VALUE_FLOAT: node = serd_node_new_decimal(value->val.float_val, 8); - result = (char*)node.buf; + result = lilv_strdup((char*)node.buf); + serd_node_free(&node); break; } diff --git a/src/state.c b/src/state.c index 2b6b113..3841c75 100644 --- a/src/state.c +++ b/src/state.c @@ -618,7 +618,7 @@ new_state_from_model(LilvWorld* world, sord_node_free(world->world, state_node); sord_node_free(world->world, statep); - free((void*)chunk.buf); + serd_free((void*)chunk.buf); sratom_free(sratom); if (state->props.props) { @@ -1153,7 +1153,10 @@ lilv_state_to_string(LilvWorld* world, serd_writer_free(writer); serd_env_free(env); - return (char*)serd_chunk_sink_finish(&chunk); + char* str = (char*)serd_chunk_sink_finish(&chunk); + char* result = lilv_strdup(str); + serd_free(str); + return result; } static void -- cgit v1.2.1