From ed8463261c9d37d6994bacf91e9e3a6e3197668e Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 8 Mar 2012 17:12:45 +0000 Subject: Fix memory errors. git-svn-id: http://svn.drobilla.net/lad/trunk/lilv@4029 a436a847-0d15-0410-975c-d299462d15a1 --- test/test_plugin.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'test/test_plugin.c') diff --git a/test/test_plugin.c b/test/test_plugin.c index b0691ed..7a2e82f 100644 --- a/test/test_plugin.c +++ b/test/test_plugin.c @@ -277,6 +277,7 @@ save(LV2_Handle instance, map_uri(plugin, LV2_ATOM__Path), LV2_STATE_IS_PORTABLE); free(apath); + free(spath); } } } @@ -316,12 +317,12 @@ restore(LV2_Handle instance, &size, &type, &valflags); if (apath) { - char* path = map_path->absolute_path(map_path->handle, apath); - FILE* f = fopen(path, "r"); - char str[8]; - fread(str, 1, sizeof(str), f); + char* path = map_path->absolute_path(map_path->handle, apath); + FILE* f = fopen(path, "r"); + char str[8]; + size_t n_read = fread(str, 1, sizeof(str), f); fclose(f); - if (strcmp(str, "Hello\n")) { + if (strncmp(str, "Hello\n", n_read)) { fprintf(stderr, "error: Restored bad file contents `%s' != `Hello'\n", str); } @@ -340,6 +341,7 @@ restore(LV2_Handle instance, } else { fclose(sfile); } + free(spath); } else { fprintf(stderr, "error: Failed to restore save file.\n"); } -- cgit v1.2.1