fixing a possible NULL deref
fix an off-by-one bug when copying varargs