int i; is uninitialised when bars = NULL;