Bones affecting wrong part of mesh

As you can see my leg bone affect the mirrored part of the mesh. This is obviously not right.



Here are the things i tried:

  • applied mirror modifier
  • weight paint

The strange thing is that this only happens in the back legs and not the front ones. So how can I fix this?

Fixed it by deleting armature modifier and re-adding it again.