X-Git-Url: http://git.home-dn.net/?p=manu%2Fsuphp.git;a=blobdiff_plain;f=src%2FCommandLine.cpp;h=6215a8f03b2f880aab064c86d04ae0131a1a0b62;hp=b718dc4fd4770eba8ae84ad94d55067d2b093408;hb=47bcf8ba77fa8011f9be728c23dbe6915d70251b;hpb=1d5c20a335c25ab89adf2e0d3d74c810b679e719 diff --git a/src/CommandLine.cpp b/src/CommandLine.cpp index b718dc4..6215a8f 100644 --- a/src/CommandLine.cpp +++ b/src/CommandLine.cpp @@ -37,8 +37,11 @@ int suPHP::CommandLine::count() const { std::string suPHP::CommandLine::getArgument(int pos) const throw (OutOfRangeException) { + if (pos >= this->arguments.size() || pos < 0) { + throw OutOfRangeException("Index out of range", __FILE__, __LINE__); + } try { - return this->arguments.at(pos); + return this->arguments[pos]; } catch (std::out_of_range& e) { throw OutOfRangeException("Index out of range", __FILE__, __LINE__); } @@ -50,7 +53,7 @@ void suPHP::CommandLine::setArgument(int pos, std::string arg) { this->arguments.push_back(std::string("")); } } - this->arguments.at(pos) = arg; + this->arguments[pos] = arg; } void suPHP::CommandLine::putArgument(std::string arg) { @@ -59,8 +62,11 @@ void suPHP::CommandLine::putArgument(std::string arg) { std::string& suPHP::CommandLine::operator[](int index) throw (OutOfRangeException) { + if (index >= this->arguments.size() || index < 0) { + throw OutOfRangeException("Index out of range", __FILE__, __LINE__); + } try { - return this->arguments.at(index); + return this->arguments[index]; } catch (std::out_of_range& ex) { throw OutOfRangeException("Index out of range", __FILE__, __LINE__); }