From db6c88f4bd10f8d488290db783b363dcfa50d3ac Mon Sep 17 00:00:00 2001 From: Jean Pierre Cimalando Date: Mon, 6 Jul 2020 14:05:46 +0200 Subject: [PATCH] lv2: fix the situation when restore proceeds after a failed path mapping --- lv2/sfizz.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/lv2/sfizz.c b/lv2/sfizz.c index d7c7e93f..56b7f0bc 100644 --- a/lv2/sfizz.c +++ b/lv2/sfizz.c @@ -993,11 +993,14 @@ restore(LV2_Handle instance, status = LV2_STATE_ERR_UNKNOWN; } - strncpy(self->sfz_file_path, path, MAX_PATH_SIZE); - self->sfz_file_path[MAX_PATH_SIZE - 1] = '\0'; + if (path) + { + strncpy(self->sfz_file_path, path, MAX_PATH_SIZE); + self->sfz_file_path[MAX_PATH_SIZE - 1] = '\0'; - if (map_path) - free_path->free_path(free_path->handle, (char *)path); + if (map_path) + free_path->free_path(free_path->handle, (char *)path); + } } value = retrieve(handle, self->sfizz_scala_file_uri, &size, &type, &val_flags); @@ -1011,11 +1014,14 @@ restore(LV2_Handle instance, status = LV2_STATE_ERR_UNKNOWN; } - strncpy(self->scala_file_path, path, MAX_PATH_SIZE); - self->scala_file_path[MAX_PATH_SIZE - 1] = '\0'; + if (path) + { + strncpy(self->scala_file_path, path, MAX_PATH_SIZE); + self->scala_file_path[MAX_PATH_SIZE - 1] = '\0'; - if (map_path) - free_path->free_path(free_path->handle, (char *)path); + if (map_path) + free_path->free_path(free_path->handle, (char *)path); + } } value = retrieve(handle, self->sfizz_num_voices_uri, &size, &type, &val_flags);