Fix Bug 884: No malloc for zero-sized matrices or for Ref without temporaries
manually ported from cbe72de483f9

--HG--
branch : 3.2