On Tue, May 6, 2008 at 4:05 PM, Michael Goffioul <[EMAIL PROTECTED]> wrote: > On Tue, May 6, 2008 at 3:35 PM, Michael Goffioul > > <[EMAIL PROTECTED]> wrote: > > > > HMMMMMMMM??? > > > > src/ann/bindings/tests/octave/ > > I looked further and while debugging, I found suspicious code > in octave_swig_packed::copy: > > std::copy(&buf[0], &buf[sz], (char*)ptr); > > While this looks nice, this code is accessing memory > outside the allocated area for buf: when sz == buf.size(), > then buf[sz] is outside the bounds of buf. When replacing > it with: > > memcpy(ptr, &buf[0], sz); > > everything works fine. >
One can also safely use std::copy(buf, buf+sz, (char*) ptr) to stay within STL algorithms. I'm sure that `buf+sz' is allowed; I don't know about `&buf[sz]'. `buf[sz]' alone is definitely not allowed. > Another source of null-referencing is in octave_swig_packed::print: > as "type" can be NULL, type->name is unsafe. One example of > such object is created in SWIG_Octave_SetModule. > > > > Michael. > > ------------------------------------------------------------------------- > This SF.net email is sponsored by the 2008 JavaOne(SM) Conference > Don't miss this year's exciting event. There's still time to save $100. > Use priority code J8TL2D2. > > http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone > _______________________________________________ > Octave-dev mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/octave-dev > -- RNDr. Jaroslav Hajek computing expert Aeronautical Research and Test Institute (VZLU) Prague, Czech Republic url: www.highegg.matfyz.cz ------------------------------------------------------------------------- This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone _______________________________________________ Octave-dev mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/octave-dev
