Well one of easiest ways would be just giving hero an ability to move the "warehouse" unit from whereever it came to hero and then teleport it back.
Also, you may create a Backpack hero which would be a hero with no abilities and model and couldn't move or attack, bould would have an inventory and every x seconds it would be moved to the real hero.
Those two are easiest ways, but they are not the most effiecient and you should fix the leaks on them...