]> de.git.xonotic.org Git - xonotic/netradiant.git/commitdiff
fixed crash when loading invalid ASE models
authorspog <spog>
Sun, 19 Feb 2006 16:43:59 +0000 (16:43 +0000)
committerspog <spog>
Sun, 19 Feb 2006 16:43:59 +0000 (16:43 +0000)
git-svn-id: svn://svn.icculus.org/gtkradiant/GtkRadiant/trunk@12 8a3a26a2-13c4-0310-b231-cf6edde360e5

CHANGES
libs/picomodel/picomodel.c
libs/picomodel/pm_ase.c
radiant/GtkRadiant.vcproj
radiant/console.cpp

diff --git a/CHANGES b/CHANGES
index 7038429a80d1743c2451d88631472818e18f40aa..7165be6490c49a9a8b711caee4828fdef7c83f11 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,10 @@
 This is the changelog for developers, != changelog for the end user 
 that we distribute with the binaries. (see changelog)
 
+19/02/2006
+SPoG
+- Fixed crash when loading invalid ASE models.
+
 11/02/2006
 SPoG
 - Added install.py script.
index 618cc8a4f50430836f62b6fc6261728c9a23df05..240d729b3f2f8a419e6bb8c22bd8c15e07ed0cbd 100644 (file)
@@ -295,7 +295,10 @@ picoModel_t        *PicoModuleLoadModelStream( const picoModule_t* module, void* inputS
                model = PicoModuleLoadModel(module, fileName, buffer, bufSize, frameNum);
        }
        
-       _pico_free(buffer);
+  if(model != 0)
+  {
+         _pico_free(buffer);
+  }
 
        /* return */
        return model;
index afcf550f0cdb5a0521bd6d5cda287c3790899b85..2450075875a78f419fc0098fbd9ce92bf85b1357 100644 (file)
@@ -755,19 +755,19 @@ static picoModel_t *_ase_load( PM_PARAMS_LOAD )
                        int                     index;
 
                        if( numVertices == 0 )
-                               _ase_error_return("Vertex parse error");
+                               _ase_error_return("Texture Vertex parse error");
 
                        /* get uv vertex index */
-                       if (!_pico_parse_int( p,&index ))
-                               _ase_error_return("UV vertex parse error");
+                       if (!_pico_parse_int( p,&index ) || index >= numTextureVertices)
+                               _ase_error_return("Texture vertex parse error");
 
                        /* get uv vertex s */
                        if (!_pico_parse_float( p,&texcoords[index].texcoord[0] ))
-                               _ase_error_return("UV vertex parse error");
+                               _ase_error_return("Texture vertex parse error");
 
                        /* get uv vertex t */
                        if (!_pico_parse_float( p,&texcoords[index].texcoord[1] ))
-                               _ase_error_return("UV vertex parse error");
+                               _ase_error_return("Texture vertex parse error");
                        
                        /* ydnar: invert t */
                        texcoords[index].texcoord[ 1 ] = 1.0f - texcoords[index].texcoord[ 1 ];
index 09856f9ed1dc2b7cd2213b3a5bdfe10eec58d0a6..461793ef4519f5f9a975fd1397cffc71d75d0193 100644 (file)
@@ -644,7 +644,7 @@ copy &quot;$(TargetDir)$(TargetName).pdb&quot;  &quot;$(SolutionDir)install&quot
                        </File>\r
                </Filter>\r
                <File\r
-                       RelativePath="..\docs\developer\Changes">\r
+                       RelativePath="..\Changes">\r
                </File>\r
                <File\r
                        RelativePath="..\debug.py">\r
@@ -683,7 +683,7 @@ copy &quot;$(TargetDir)$(TargetName).pdb&quot;  &quot;$(SolutionDir)install&quot
                        RelativePath="..\SConstruct">\r
                </File>\r
                <File\r
-                       RelativePath="..\docs\developer\Todo">\r
+                       RelativePath="..\Todo">\r
                </File>\r
                <File\r
                        RelativePath="..\touch.py">\r
index df75c61e44ce2b9ec7cae5c4c6f7d25cf6653b07..5c462405074cb35905d73cbf2e86232f0d831cda 100644 (file)
@@ -137,6 +137,22 @@ GtkWidget* Console_constructWindow(GtkWindow* toplevel)
   return scr;
 }
 
+class GtkTextBufferOutputStream : public TextOutputStream
+{
+  GtkTextBuffer* textBuffer;
+  GtkTextIter* iter;
+  GtkTextTag* tag;
+public:
+  GtkTextBufferOutputStream(GtkTextBuffer* textBuffer, GtkTextIter* iter, GtkTextTag* tag) : textBuffer(textBuffer), iter(iter), tag(tag)
+  {
+  }
+  std::size_t write(const char* buffer, std::size_t length)
+  {
+    gtk_text_buffer_insert_with_tags(textBuffer, iter, buffer, gint(length), tag, 0);
+    return length;
+  }
+};
+
 std::size_t Sys_Print(int level, const char* buf, std::size_t length)
 {
   bool contains_newline = strchr(buf, '\n') != 0;
@@ -190,18 +206,16 @@ std::size_t Sys_Print(int level, const char* buf, std::size_t length)
       }
 
 
-      StringOutputStream converted;
+      GtkTextBufferOutputStream textBuffer(buffer, &iter, tag);
       if(!globalCharacterSet().isUTF8())
       {
-        converted << ConvertLocaleToUTF8(StringRange(buf, buf + length));
+        textBuffer << ConvertLocaleToUTF8(StringRange(buf, buf + length));
       }
       else
       {
-        converted << StringRange(buf, buf + length);
+        textBuffer << StringRange(buf, buf + length);
       }
 
-      gtk_text_buffer_insert_with_tags(buffer, &iter, converted.c_str(), gint(string_length(converted.c_str())), tag, 0);
-
       // update console widget immediatly if we're doing something time-consuming
       if(contains_newline)
       {