From a83eebb3698999e80197e96072a5ad8820cd5c5e Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 1 Sep 2008 20:32:53 +0000 Subject: [PATCH] Fix array bounds checking in C# std::vector wrappers git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10804 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++++ Lib/csharp/std_vector.i | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 56a385d57..bd601bee7 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,10 @@ Version 1.3.37 (in progress) ============================= +2008-09-01: wsfulton + [C#] Correct array bounds checking in std::vector typemaps - Insert and InsertRange + methods. + 2008-08-02: wuzzeb [Chicken,Allegro] Commit Patch 2019314 Fixes a build error in chicken, and several build errors and other errors diff --git a/Lib/csharp/std_vector.i b/Lib/csharp/std_vector.i index a04831f75..2e4d47c00 100755 --- a/Lib/csharp/std_vector.i +++ b/Lib/csharp/std_vector.i @@ -231,14 +231,14 @@ return new std::vector(self->begin()+index, self->begin()+index+count); } void Insert(int index, const value_type& x) throw (std::out_of_range) { - if (index>=0 && index<(int)self->size()+1) + if (index>=0 && index<(int)self->size()) self->insert(self->begin()+index, x); else throw std::out_of_range("index"); } // Takes a deep copy of the elements unlike ArrayList.InsertRange void InsertRange(int index, const std::vector& values) throw (std::out_of_range) { - if (index>=0 && index<(int)self->size()+1) + if (index>=0 && index<(int)self->size()) self->insert(self->begin()+index, values.begin(), values.end()); else throw std::out_of_range("index");