Yes, I apprecaite how you feel about it, I think, for sure its a very crude protection,but it would work and ensure a return under all conditions.
As I understand it, the issue is not in setting the cursor active, as any positive value returned would confirm that status, but to ensure that the cursor is disabled, which requires a zero or lower count, hence the need for a loop to continue calls to decrement the value.
Microsoft´s coding seems sort of wooly, with no clear on/off control, and I guess this is to cope with multiple requests from multiple apps to enable/disable the cursor, but still, I don´t like the concept for its lack of clarity, something which the structure of Irrlich has in its favour.
So every call to setcursor with a zero value will decrement the value, but if there is another app calling to enable the cursor, it will be a war of time-slice, with no certain winner, and the possiblity that the call may never return.
The only way to prevent that is to use a loop counter limit, and abandon the attempt to disable the cursor after 100 or so cycles, IMHO.
Nasty as that is to any purist software engineer*, its how it seems to be, to me, but I´m open to alternative ideas!