diff options
author | David Robillard <d@drobilla.net> | 2012-03-08 17:12:45 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2012-03-08 17:12:45 +0000 |
commit | ed8463261c9d37d6994bacf91e9e3a6e3197668e (patch) | |
tree | 1f4510050f63847fd2d993970d62fabb5594410b /test/test_plugin.c | |
parent | b1e37ba0fb6fe83e823140a57cbbe79fd485d86e (diff) | |
download | lilv-ed8463261c9d37d6994bacf91e9e3a6e3197668e.tar.gz lilv-ed8463261c9d37d6994bacf91e9e3a6e3197668e.tar.bz2 lilv-ed8463261c9d37d6994bacf91e9e3a6e3197668e.zip |
Fix memory errors.
git-svn-id: http://svn.drobilla.net/lad/trunk/lilv@4029 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'test/test_plugin.c')
-rw-r--r-- | test/test_plugin.c | 12 |
1 files changed, 7 insertions, 5 deletions
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"); } |