On Sun, Dec 30, 2018 at 01:24:40PM +0100, Jürgen Spitzmüller wrote:
> Am Sonntag, den 30.12.2018, 12:21 +0000 schrieb José Abílio Matos:
> > I can rephrase: should we just fix this line, that can become
> > obviously wrong,
> > or should we try to cure the cause and not just the symptom?
> >
> > In this case the problem is that the "from name" and the "to name"
> > are equal.
> > Should we rule out those cases, or try to accommodate them in our
> > framework?
>
> I'd say the latter.
For some reason it doesn't crash for me, but I see where the problem
lies. In computing the length of the extension, the code does not
account for the prefix "unzipped_" which is added when the zipped
filename does not have one of the extensions "gz", "z", "Z", or "svgz".
Please, can you try the attached patch and report whether it fixes the
crash for you?
--
Enrico
diff --git a/src/insets/InsetGraphics.cpp b/src/insets/InsetGraphics.cpp
index c1d9822b93..70b7780910 100644
--- a/src/insets/InsetGraphics.cpp
+++ b/src/insets/InsetGraphics.cpp
@@ -587,7 +587,10 @@ copyToDirIfNeeded(DocFileName const & file, string const &
dir)
// have different content but would get the same mangled
// name in this case.
string const base = removeExtension(file.unzippedFileName());
- string::size_type const ext_len = file_in.length() -
base.length();
+ string::size_type const prefix_len =
+ prefixIs(onlyFileName(base), "unzipped_") ? 9 : 0;
+ string::size_type const ext_len =
+ file_in.length() + prefix_len - base.length();
mangled[mangled.length() - ext_len] = '.';
}
FileName const file_out(makeAbsPath(mangled, dir));