From 0532f9be37ca66c68d98d1a68530a17041c11fc2 Mon Sep 17 00:00:00 2001
From: Paul Licameli <paul.licameli@audacityteam.org>
Date: Wed, 22 Nov 2017 22:40:01 -0500
Subject: [PATCH] More sanity checking in file save ...

... against corruption as seen in:

http://forum.audacityteam.org/viewtopic.php?f=47&t=97787

Maybe this early check would have alerted the user sooner and prevented
trouble.
---
 src/DirManager.cpp | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/DirManager.cpp b/src/DirManager.cpp
index 86cf32647a..3b7f2333cc 100644
--- a/src/DirManager.cpp
+++ b/src/DirManager.cpp
@@ -1370,7 +1370,11 @@ std::pair<bool, wxString> DirManager::CopyToNewProjectDirectory(BlockFile *f)
    }
 
    wxFileNameWrapper newFileName;
-   if (!this->AssignFile(newFileName, oldFileNameRef.GetFullName(), false))
+   if (!this->AssignFile(newFileName, oldFileNameRef.GetFullName(), false)
+       // Another sanity check against blockfiles getting reassigned an empty
+       // name, as apparently happened in
+       // http://forum.audacityteam.org/viewtopic.php?f=47&t=97787 :
+       || newFileName.GetFullName().empty() )
       return { false, {} };
 
    if (newFileName != oldFileNameRef) {
-- 
GitLab