From: Martin Buchan <M.J.Buchan@gre.ac.uk>
To: linux-c-programming@vger.kernel.org
Cc: "Jason P. Winters" <jason@txt.com>
Subject: Re: segfault with strdup
Date: Tue, 20 May 2003 14:52:54 +0100 [thread overview]
Message-ID: <20030520135254.GD674@gre.ac.uk> (raw)
In-Reply-To: <200305201316.h4KDGUhG007842@grinch.txt.com>
On Tue, May 20, 2003 at 06:15:58AM -0700, Jason P. Winters wrote:
>
> > The place where it is seg faulting is
> >
> > uri = xmlGetProp(cur, "name");
> > mePtr[i].appname = strdup(uri); /* HERE */
>
> Well, I don't have a lot of time to spend on it, but here are a
> couple of observations:
>
> First and formost: you're not testing the result of xmlGetProp for
> null. This is probably your "problem", as you then try and dup a
> null string. Bad habit, that. :}
Point taken :-)
Now i am testing for NULL but i still get the same problem. However,
i do not think this is the probelm because if i step thru the
program with ddd, just before it segfaults at the line
mePtr[i].appname = strdup(uri);
If i hover the mouse over the previous line:
uri = xmlGetProp(cur, "name");
It shows me that the value of uri is "Netscape Navigator"
Also, if this was the case (and i wish it was cos then i could fix
it :) then that would apply to the directory where the code works in
as well as any other directory.??
thanks for pointing out testing for NULL though.
Martin
next prev parent reply other threads:[~2003-05-20 13:52 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-05-20 11:20 segfault with strdup Martin Buchan
2003-05-20 12:25 ` Chris Nanakos
2003-05-20 12:46 ` Martin Buchan
2003-05-20 13:12 ` Martin Buchan
[not found] ` <200305201316.h4KDGUhG007842@grinch.txt.com>
2003-05-20 13:52 ` Martin Buchan [this message]
2003-05-20 16:32 ` Glynn Clements
2003-05-21 9:50 ` Martin Buchan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20030520135254.GD674@gre.ac.uk \
--to=m.j.buchan@gre.ac.uk \
--cc=jason@txt.com \
--cc=linux-c-programming@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).