go-gl/gl — pull request #68 by jteeuwen (2012-10-11 17:57:46+00:00)
Title: Fixes for potential slice indexing errors.

This patch fixes a number of functions which accept slices as parameters and proceed to index the slice without verifying that it has the correct size. These will not panic, but silently operate on garbage memory.

The fixes employ a simply length check on the input slice. If this check fails, the function panics. they do not return an error because the errors are severe enough that they can lead to memory corruption in some cases. This warrants stopping the world outright.

I have tested this change on a number of GL programs and so far all of them work as expected. However, this covers a sizable number of changes to the code. And should therefore be carefully reviewed.

As a side note: I found a few other potential bugs while writing this. They have not been fixed in this patch, but marked with a `FIXME` comment, so they may be reviewed.