Blame SOURCES/djvulibre-3.5.27-djvuport-stack-overflow.patch

a9380a
diff --git a/libdjvu/DjVuPort.cpp b/libdjvu/DjVuPort.cpp
a9380a
index 2b3e0d2..ede7f6b 100644
a9380a
--- a/libdjvu/DjVuPort.cpp
a9380a
+++ b/libdjvu/DjVuPort.cpp
a9380a
@@ -507,10 +507,19 @@ GP<DjVuFile>
a9380a
 DjVuPortcaster::id_to_file(const DjVuPort * source, const GUTF8String &id)
a9380a
 {
a9380a
    GPList<DjVuPort> list;
a9380a
+
a9380a
+   if (!!opening_id && opening_id == id)
a9380a
+      G_THROW("DjVuPortcaster: recursive opening of the same file (corrupted file?)");
a9380a
+   else
a9380a
+      opening_id = id;
a9380a
+
a9380a
    compute_closure(source, list, true);
a9380a
    GP<DjVuFile> file;
a9380a
    for(GPosition pos=list;pos;++pos)
a9380a
       if ((file=list[pos]->id_to_file(source, id))) break;
a9380a
+
a9380a
+   opening_id = GUTF8String();
a9380a
+
a9380a
    return file;
a9380a
 }
a9380a
 
a9380a
diff --git a/libdjvu/DjVuPort.h b/libdjvu/DjVuPort.h
a9380a
index e2b3125..313dc2b 100644
a9380a
--- a/libdjvu/DjVuPort.h
a9380a
+++ b/libdjvu/DjVuPort.h
a9380a
@@ -484,6 +484,7 @@ private:
a9380a
                        const DjVuPort *dst, int distance);
a9380a
    void compute_closure(const DjVuPort *src, GPList<DjVuPort> &list,
a9380a
                         bool sorted=false);
a9380a
+   GUTF8String opening_id;
a9380a
 };
a9380a
 
a9380a