The first query returned NO data.. so the variable is already SET and the program flow continued.. and since you refer it inside a loop before unsetting it.. instead of checking on no data for a cursor as you expected.!!
SELECT data into data_inicio FROM dia WHERE tem_corrente = 1 and inicio_corrente = 1 and data < data_selecionada order by data desc limit 1;
IF existe_mais_linhas = 1 THEN
SET existe_mais_linhas = 0;-- unset it using SET..
END IF;
OPEN meuCursor;
meuLoop: LOOP
FETCH meuCursor INTO dia_atual, semana_atual, inicio;
IF existe_mais_linhas = 1 THEN
LEAVE meuLoop;
END IF;
-- Move the insert after checking it!
insert into log (cont) values (1);
END LOOP meuLoop;