Article View: gnu.g++.lib.bug
Article #21Correction to libg++2.0 String: :OK
From: John Messenger
Date: Wed, 01 Apr 1992 18:00
Date: Wed, 01 Apr 1992 18:00
34 lines
1770 bytes
1770 bytes
This is the OK function from the String class in libg++2.0. If you
haven't got GNU ld, this is where you end up with a core dump because
rep (zero) is dereferenced. Might I suggest this mod to String::OK
and similar functions to protect against dereferencing NULL pointers
and also beg for a suitable comment in the libg++ README and .texinfo
files telling you that you need support in the linker for
initialisation of constructors (such as is provided by GNU ld and not
provided by for example SunOS ld).
-- John Messenger.
PS Please reply as I'm not sure if my mail makes it.
------------ Context diff follows ----------------------------
*** String.cc-dist Wed Apr 1 14:47:22 1992
--- String.cc Wed Apr 1 14:49:55 1992
***************
*** 1305,1313 ****
int String::OK() const
{
! int v = rep != 0; // have a rep
! v &= rep->len <= rep->sz; // string within bounds
! v &= rep->s[rep->len] == 0; // null-terminated
if (!v) error("invariant failure");
return v;
}
--- 1305,1313 ----
int String::OK() const
{
! int v = rep != 0; // have a rep
! v = v && rep->len <= rep->sz; // string within bounds
! v = v && rep->s[rep->len] == 0; // null-terminated
if (!v) error("invariant failure");
return v;
}
Technical Details
Message-ID:
<memo.362196@cix.compulink.co.uk>Path:
arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!cix.CLink.co.UK!jmessengerShow Full Headers
Complete Article Headers
Newsgroups: gnu.g++.lib.bug Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!cix.CLink.co.UK!jmessenger From: jmessenger@cix.CLink.co.UK (John Messenger) Subject: Correction to libg++2.0 String: :OK Message-ID: <memo.362196@cix.compulink.co.uk> Sender: gnulists@ai.mit.edu Reply-To: jmessenger@cix.clink.co.uk Organization: GNUs Not Usenet Distribution: gnu Date: Wed, 1 Apr 1992 18:00:00 GMT Approved: bug-lib-g++@prep.ai.mit.edu Lines: 35