Source-Changes-D archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: CVS commit: src/sys/miscfs/genfs



> Log Message:
> Revert part which variable initializations within interleaved gotos.
> 
> again:
>       if (...) goto err;
>       void *ptr = alloc();
>       if (...) goto again;
>       if (...) goto err1;
>       ...
> err1: if (ptr) free(ptr);
> err:
>       return;
> 
> This leaks memory if exited with "goto again; -> goto err;".

Actually it did NOT.  Because the "if (...) goto again;" part carefully
free()'ed the object.  In the actual code:

    312         if (vp->v_size < origvsize) {
    313                 rw_exit(&gp->g_glock);
    314                 if (pgs != pgs_onstack)
    315                         kmem_free(pgs, pgs_size);
    316                 goto startover;
    317         }

Masao

-- 
Masao Uebayashi / Tombi Inc. / Tel: +81-90-9141-4635


Home | Main Index | Thread Index | Old Index