I'm not looking at it as a character thing, but as a narrative thing.
Of course she has reason to hug him, same as Tenten or Shino, or unnamed background ninja #453, and it's reasonable for each to do that.
There were plenty of opportunities for Sakura to show affection to Nardo, none of which I minded even as a Hinatafag. After the Kakuzu fight she fed him, and it's actually disappointing that (to my memory) she doesn't console Naruto after their pathetic failure at Orochimaru's base.
Her showing direct and great skill at her own profession, ingenuity in a stressful situation and determination to keep a friend alive was a very good bit of characterisation, the kind she needed more of.
Hell, treating it on just its own, I have more of a problem with Sakura first feeling the need to punch Naruto, and only then hugging him, unless the express intention was to show her being a cunt.
But in that place, delivering the character payoff with her was still a bad move for the structure of the story overall.
If it was Sakura who stepped in front of Pein and Hinata who ended up hugging Naruto, it would still be bad.
Hinata stepping into the fight tied into affection, protecting a loved one, anger at being hurt and the wish to avenge, with Naruto choosing to spare Nagato, showed a way out.
It accompanied a larger attack and a lot of other damage, but by tying it all into one person getting hurt without Naruto being able to stop it right in front of him, it was presented in a small, tidy package.
After he comes back, greeted by the crowd, it would thus make far more sense structurally for the hug to be given by Hinata. Close off that worry and sense of damage in one action, show appreciation of that sacrifice that Hinata herself made as a character without letting that dangle around unresolved for (IRL) years.
But status quo had to be preserved and character growth avoided, so Sakura, mostly irrelevant for the arc, was used instead.