On second-order linear differential equations with algebraic solutions on algebraic curves