Proposed fix for coverity #29372
[supertux.git] / src / supertux / console.cpp
index 43d09e7..7244191 100644 (file)
@@ -19,7 +19,7 @@
 #include <math.h>
 #include <iostream>
 
-#include "physfs/ifile_stream.hpp"
+#include "physfs/buffered_ifile_stream.hpp"
 #include "scripting/scripting.hpp"
 #include "scripting/squirrel_util.hpp"
 #include "supertux/gameconfig.hpp"
@@ -175,8 +175,9 @@ Console::ready_vm()
 
     try {
       std::string filename = "scripts/console.nut";
-      IFileStream stream(filename);
-      scripting::compile_and_run(m_vm, stream, filename);
+      BufferedIFileStream* buffered_stream = new BufferedIFileStream(filename);
+      IFileStream* stream = buffered_stream->get_stream();
+      scripting::compile_and_run(m_vm, *stream, filename);
     } catch(std::exception& e) {
       log_warning << "Couldn't load console.nut: " << e.what() << std::endl;
     }
@@ -424,10 +425,9 @@ Console::parse(std::string s)
 
   // split line into list of args
   std::vector<std::string> args;
-  size_t start = 0;
   size_t end = 0;
   while (1) {
-    start = s.find_first_not_of(" ,", end);
+    size_t start = s.find_first_not_of(" ,", end);
     end = s.find_first_of(" ,", start);
     if (start == s.npos) break;
     args.push_back(s.substr(start, end-start));