Fix handling of glUniform*v functions.
The count field is the number of variables not the number of elements.
Additionally fix a TODO and support setting arrays of matrices.
Also adds checks if the temporary buffer allocation fails.
Thanks to Ryan Alexander for the original patch.