If you have sufficient expertise on the subject, you can post an answer which begins by explaining why a particular approach mentioned in the comments is wrong:
Some have suggested using [wrong/dangerous approach], but this is a bad idea...
Then go on to explain why the approach is wrong. If it's "demonstrably wrong" then you should demonstrate why it's wrong (assuming you can do so without harming yourself).1 Finally, to complete your answer you need to explain what you think is the right approach. The explanation of the right approach may be as simple as linking to another answer which already explains it. (Alternatively, you can begin your answer with the right approach and end it with an explanation of what not to do.)
Then you can reply to the commenter who suggested the wrong approach and ask him to review your answer which explains why that is a bad idea.
If you can't provide an answer then you can at least reply to the commenter who suggested the wrong approach and say that you think the approach is wrong (and, briefly, why you think so). You can also comment on the question and tell the asker that the approach suggested in one of the comments should be avoided. A comment on the question ensures that the asker is notified of your concerns.
Flagging the comment is definitely not the recommended response since moderators aren't necessarily experts in the subject matter and may not be able to judge whether or not the suggested approach is wrong/dangerous. Even if the moderator deleted the comment, what's to stop someone from suggesting the wrong/dangerous approach again? It's better for the comment to remain so that members of the community can discuss the pros and cons of the approach, either in the comments or in answers.
1Stack Overflow Meta has some useful guidelines on how to post malicious code.