Raise error when buffer gets data of size zero

Fix #661 
cc @lcampagn