There is a theorem stating that there is a one-to-one correspondence between connected Lie subgroups of a Lie group and subalgebras of its Lie algebra.
Note that $GL(n,\mathbb{R})$ is a closed Lie subgroup of $GL(n,\mathbb{C})$ and $gl(n,\mathbb{R})$ is a Lie subalgebra of $gl(n,\mathbb{C})$. By the above theorem, $GL(n,\mathbb{R})$ must be connected, but it is not.
What am I misunderstanding here?
The Lie agebra of $Gl(n,\mathbb{R})$ is also the Lie algebra of its connected component which is the subset of elements with positive determinant.