There is no problem to buffer pills, since both Mg(OH)2 and MgCO3 are used as solids. Of course, during dissolution aspirin can react with this compounds, but in stomach a much stronger acid exists, namely hydrochloric acid.
These compounds are used for rising pH in stomach during dissolution to avoid side effects of aspirin to stomach mucous membrane.