Accidentals indeed are supposed to apply only to the octave in which they are written, for the duration of the measure.I always wonder, though, why I so often see naturals written unnecessarily in one measure when the last sharp or flat on that pitch was in the previous measure....