If there are no significant improvements to the paper by the "second" author, such acts of "sniping" might be treated by the math community as academic theft, and the second author might not get any credit at all. If anything, their reputation might be seriously damaged.
This is exactly what happened with Perelman's proof of the Poincare conjecture: https://www.newyorker.com/magazine/2006/08/28/manifold-desti...