Thread View: gnu.g++.lib.bug
1 messages
1 total messages
Started by John Messenger
Wed, 01 Apr 1992 18:00
Correction to libg++2.0 String: :OK
Author: 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;
}
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads