found=NULL; for (surf = This->attached; surf != NULL; surf = surf->next_attached){ ... // surf is not modified into that if (...) found=surf; } if (found == NULL) { TRACE("Did not find any valid surface\n"); return DDERR_NOTFOUND; }
Well, we loop on 'surf' (which will be NULL at the end of the loop) and test 'found' (that won't be NULL if a matching surface was found). So no, I do not see any problem here.
Lionel