From kde-core-devel Wed Feb 27 15:36:44 2002 From: David Faure Date: Wed, 27 Feb 2002 15:36:44 +0000 To: kde-core-devel Subject: Re: Segfault Bug in KURL X-MARC-Message: https://marc.info/?l=kde-core-devel&m=101482438108965 On Wednesday 27 February 2002 14:41, Benjamin Meyer wrote: > He is the sinario: > > This caused a segfault for me: > void foo(KURL url){ > KURL *p = newKURL(url); > } KURL is usually built on the stack (KURL blah) rather than on the heap (new). When passing as parameter, prefer to pass objects by reference than by value. > This didn't: > void foo(KURL url){ > KURL *p = newKURL(); > p->setPath(url->path()); > } This can't compile (url is an object, and you access it with "->"). and to set a URL to another one, just KURL a = b; There isn't enough code here to see what could possibly be crashing anyway, but those uses of pointers make it likely that you have an unset pointer somewhere. -- David FAURE, david@mandrakesoft.com, faure@kde.org http://people.mandrakesoft.com/~david/, http://www.konqueror.org/ KDE, Making The Future of Computing Available Today