Index: src/libcschem/plug_io.c =================================================================== --- src/libcschem/plug_io.c (revision 10362) +++ src/libcschem/plug_io.c (revision 10363) @@ -560,6 +560,11 @@ if (!preserve_name && ((stype == SS_SAVE_SHEET) || (stype == SS_SAVE_SHEET_AS_SYM))) { char *newname = rnd_lrealpath(fn); + if (newname == NULL) { + rnd_message(RND_MSG_ERROR, "Failed to realpath(%s)\nMight be write permission problems\n", fn); + ret = -1; + goto error; + } if ((sheet->hidlib.fullpath == NULL) || (strcmp(sheet->hidlib.fullpath, newname) != 0)) { free(sheet->hidlib.fullpath); sheet->hidlib.fullpath = newname; @@ -586,6 +591,7 @@ break; } + error:; free(fn); vtpr_uninit(&prios); return ret;