On page 430 of Sisper's TOC, Theorem 10.39 proves $\textbf{NC}^1\subseteq \textbf{L}$:
PROOF: We sketch a log space algorithm to decide a language $A$ in $\textbf{NC}^1$ . On input $w$ of length $n$, the algorithm can construct the description as needed of the nth circuit in the uniform circuit family for $A$. Then the algorithm can evaluate the circuit by using a depth-first search from the output gate. Memory for this search is needed only to record the path to the currently explored gate, and to record any partial results that have been obtained along that path. The circuit has logarithmic depth; hence only logarithmic space is required by the simulation.
In my opinion, the algorithm would evaluate values of all gates via DFS, i.e. record the path and its partial results, then check the output gate. However, if we record the path to the currently explored gate, we will need the ID of each gate on the path. There are $n^k$ gates in the $n$th circuit, so we have $O(\log n)$ space to save each ID. Totally, the algorithm bears $O(\log^2n)$ space for the algorithm because of $O(\log n)$ depth.
I know that the proof is being taught in many lectures so far, it is probably correct but what have I missed?