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

Re: Why does this program segfault?



On Mon, Jan 14, 2002 at 07:11:53PM -0500, Jaldhar H. Vyas wrote:

>   pkgDepCache cache = *cachefile;
>   for (pkgCache::PkgIterator it = cache.PkgBegin(); !it.end(); it++)
>   {
>     if (it->CurrentState == pkgCache::State::Installed)
>     {
>       std::cout << it.Name() << ' ' << it.CurrentVer().VerStr() << endl;
>     }
>   }

This seems to be happening because pkgDepCache is trying to
free(delLocalPolicy), which is initiailzed to 0.

I think what you want is pkgCache instead of pkgDepCache.  That will avoid
the segfault and still do what you want.

-- 
 - mdz



Reply to: