Out of range access on structs leads to bad data
Jaroslav Hajek
highegg at gmail.com
Tue Aug 12 14:25:41 CDT 2008
On Tue, Aug 12, 2008 at 7:23 PM, John W. Eaton <jwe at bevo.che.wisc.edu> wrote:
> On 12-Aug-2008, Kim Hansen wrote:
>
> | Hi,
> |
> | I get this error on octave 3.0.1 (the Debian unstable package). I
> | don't have a build of the development Octave to test on.
> |
> | I expected "error: invalid vector index = 2" from line 2.
> |
> | ====================
> | octave:1> a.b=1
> | a =
> | {
> | b = 1
> | }
> |
> | octave:2> c=a(2);
> | octave:3> c
> | c =
> | {
> | b =
> |
> | error: octave_base_value::print (): wrong type argument `<unknown type>'
> |
> | }
> |
> | octave:3> d=c.b;
> | error: value on right hand side of assignment is undefined
> | error: evaluating assignment expression near line 3, column 2
> | octave:3>
>
> Try the following patch. It will catch the case you show above, but
> will still fail for something like
>
> x.a.a = 1
> x(2).a
>
> I see no simple way to completely fix this problem without also
> breaking the following valid code:
>
> x(1).a.a = 1
> x(2).a.a = 2
>
> The code in Octave that handles indexed assignment is what really
> needs to be fixed so that we can allow resizing when an index
> expression is on the left side of an assignment and properly detect
> the index-out-of-range error when it is not. But that is a large
> and relatively risky change and so I don't see it happening before the
> 3.2 release. At least it is just a missed error, not a case where we
> are failing to properly interpret valid code.
>
> jwe
>
I applied this patch also to 3.0.x
--
RNDr. Jaroslav Hajek
computing expert
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz
More information about the Bug-octave
mailing list