VirtualBox

Ignore:
Timestamp:
Oct 26, 2007 5:28:37 PM (17 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
25743
Message:

Main: Fixed memory errors and leaks found by valgrind.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxBFE/USBProxyServiceLinux.cpp

    r4071 r5523  
    840840                {
    841841                    USBINTERFACE If = {0};
     842                    bool fIfAdopted = false;
    842843                    while (*psz && VBOX_SUCCESS (rc))
    843844                    {
     
    883884                                    Assert (!If.bInterfaceNumber); Assert (!If.bAlternateSetting);
    884885                                    *pIf = If;
     886                                    fIfAdopted = true;
    885887                                }
    886888                                else
     
    895897                                pIf = &pCfg->paInterfaces[If.bInterfaceNumber];
    896898                                if (!If.bAlternateSetting)
     899                                {
     900                                    freeInterfaceMembers (pIf, 1);
    897901                                    *pIf = If;
     902                                    fIfAdopted = true;
     903                                }
    898904                                else
    899905                                {
     
    902908                                    {
    903909                                        pIf->paAlts = paAlts;
    904                                         pIf = &paAlts[pIf->cAlts++];
     910                                        // don't do pIf = &paAlts[pIf->cAlts++]; as it will increment after the assignment
     911                                        unsigned cAlts = pIf->cAlts++;
     912                                        pIf = &paAlts[cAlts];
    905913                                        *pIf = If;
     914                                        fIfAdopted = true;
    906915                                    }
    907916                                    else
     
    916925                        }
    917926                    }
     927
     928                    if (!fIfAdopted)
     929                        freeInterfaceMembers (&If, 1);
    918930
    919931                    /* start anew with endpoints. */
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette