In semiconductor lasers, current injection not only provides the optical gain, but also induces variation of the refractive index, as governed by the Kramers-Krönig relation. The linear coupling between the changes of the effective refractive index and the modal gain is described by the linewidth broadening factor, which is responsible for many static and dynamic features of semiconductor lasers. Intensive efforts have been made to characterize this factor in the past three decades. In this paper, we propose a simple, flexible technique for measuring the linewidth broadening factor of semiconductor lasers. It relies on the stable optical injection locking of semiconductor lasers, and the linewidth broadening factor is extracted from the residual side-modes, which are supported by the amplified spontaneous emission. This new technique has great advantages of insensitivity to thermal effects, the bias current, and the choice of injection-locked mode. In addition, it does not require the explicit knowledge of optical injection conditions, including the injection strength and the frequency detuning. The standard deviation of the measurements is less than 15%.