I agree, don't be there if there is a possibility of a riot.

But if caught, find someplace safe and hunker down. See which direction the riot is moving. Worst case scenario, you are in the center. Best case, you are on the outskirts and it's moving away.

If you are not the "enemy" of the riot, attempt to move slowly, sticking to the outside of the crowd if possible, away from the center of events. Sometimes you can simply walk out of the area.

Don't stop and take pictures, you might get your butt stomped by those who don't want to see their happy smiling faces on the front page. Be "grey and move away".