Am Dienstag, 28. Februar 2012 um 12:08:56, schrieb Kornel Benko <[email protected]>
> Am Dienstag, 28. Februar 2012 um 11:54:32, schrieb Pavel Sanda <[email protected]>
> > Kornel Benko wrote:
> > > Bisecting ...
> > > Ok, it started on r40791. This is the first time using the libmagic with 
> > > cmake-build.
> > 
> > This is very strange, I use autotools and get the same crash.
> > Pavel
> 
> I was hoping that it would be the same on autotools. Maybe using libmagic 
> with non-existent file
> causes this.
> 
>       Kornel
This cured it for me.
(The new magic code is enclosed in "if (filename.exists()) "

        Kornel
Index: src/Format.cpp
===================================================================
--- src/Format.cpp	(Revision 40802)
+++ src/Format.cpp	(Arbeitskopie)
@@ -375,32 +375,34 @@
 		return string();
 
 #ifdef HAVE_MAGIC_H
-	magic_t magic_cookie = magic_open(MAGIC_MIME);
-	if (magic_cookie) {
-		string format;
-		if (magic_load(magic_cookie, NULL) != 0) {
-			LYXERR(Debug::GRAPHICS, "Formats::getFormatFromFile\n"
-				<< "\tCouldn't load magic database - "
-				<< magic_error(magic_cookie));
-		} else {
-			string mime = magic_file(magic_cookie,
-				filename.toFilesystemEncoding().c_str());
-			mime = token(mime, ';', 0);
-			// we need our own ps/eps detection
-			if (mime != "application/postscript") {
-				Formats::const_iterator cit =
-					find_if(formatlist.begin(), formatlist.end(),
-					        FormatMimeEqual(mime));
-				if (cit != formats.end()) {
-					LYXERR(Debug::GRAPHICS, "\tgot format from MIME type: "
-						<< mime << " -> " << cit->name());
-					format = cit->name();
+	if (filename.exists()) {
+		magic_t magic_cookie = magic_open(MAGIC_MIME);
+		if (magic_cookie) {
+			string format;
+			if (magic_load(magic_cookie, NULL) != 0) {
+				LYXERR(Debug::GRAPHICS, "Formats::getFormatFromFile\n"
+					<< "\tCouldn't load magic database - "
+					<< magic_error(magic_cookie));
+			} else {
+				string mime = magic_file(magic_cookie,
+					filename.toFilesystemEncoding().c_str());
+				mime = token(mime, ';', 0);
+				// we need our own ps/eps detection
+				if (mime != "application/postscript") {
+					Formats::const_iterator cit =
+						find_if(formatlist.begin(), formatlist.end(),
+							FormatMimeEqual(mime));
+					if (cit != formats.end()) {
+						LYXERR(Debug::GRAPHICS, "\tgot format from MIME type: "
+							<< mime << " -> " << cit->name());
+						format = cit->name();
+					}
 				}
 			}
+			magic_close(magic_cookie);
+			if (!format.empty())
+				return format;
 		}
-		magic_close(magic_cookie);
-		if (!format.empty())
-			return format;
 	}
 #endif
 

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to