gonum / blas

A BLAS implementation for Go [DEPRECATED]
172 stars 16 forks source link

native/all: Need to explicitly check length of input slices #122

Closed btracey closed 9 years ago

btracey commented 9 years ago

In native, we use sub-slicing a lot, for example to compute dot products. However, we do not explicitly check the length of input slices. If the input slice itself comes from a larger slice, some of the routines will not panic. See for example the test program:

package main

import (
    "github.com/gonum/blas"
    "github.com/gonum/blas/native"
)

func main() {
    a := make([]float64, 0, 1000)
    x := make([]float64, 10)
    y := make([]float64, 10)

    native.Implementation{}.Dgemv(blas.NoTrans, 10, 10, 1, a, 10, x, 1, 0, y, 1)
}

The length of a is 0, but slicing extends a beyond its original length.

kortschak commented 9 years ago

blas/cgo makes these checks.

btracey commented 9 years ago

Fixed with #126