This is the mail archive of the libstdc++-prs@sourceware.cygnus.com mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

libstdc++/31: <deque> deallocates unowned memory within .pop_back()



>Number:         31
>Category:       libstdc++
>Synopsis:       <deque> deallocates unowned memory within .pop_back()
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Jan 31 22:17:00 PST 2000
>Closed-Date:
>Last-Modified:
>Originator:     Stephen M Wynne
>Release:        libstdc++-2.9.0-24
>Organization:
>Environment:
Intel RedHat 6.1
>Description:
Coredumps occur after doing a D.pop_back() on an
empty object (declared by deque<int> D;).

After quickly reading it, I can only surmize that
stl_deque.h's class deque's pop_back() mutator
properly doesn't check to see if the object is empty.
(I didn't fully understand pop_back_aux(), but it may
be pointless to go into that function if we're empty.)

Note: I did a search for pop on libstdc++ and didn't
see a report for this bug. I think it's a major one,
so I hope we can fix it soon. Thanks for the work!
>How-To-Repeat:
int main() {
    deque<int> v;
 
    v.pop_back();
    v.push_back(1);
    return 0;
}
>Fix:
Add a check inside push_back() 
(before it does anything else) as follows:

if (finish == start) return;
>Release-Note:
>Audit-Trail:
>Unformatted:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]