good thing you did give it back, I was going through something like that when I found my now dog. He was skinny to the point of ribs and backbone showing, tied up to a fence and abandoned on my road. I took him in, went in on monday to hand him over to the animal welfare to see if anyone owns him, the lady yelled at me saying taking the dog off that fence in the rain is like stealing a car. And I could go to jail for it. Mind you the dog had no tags, no collar, just a leash wrapped around his neck. I had to wait 2 weeks to see if anyone claimed the dog before he was mine.
Long story short, if they were looking for the dog and you were found with it, you could of been at the least fined for stealing the dog even if it "ran away" or was "dropped off"