octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[./src/input.cc:1268]: (error) Dangerous iterator usage.


From: CdeMills
Subject: [./src/input.cc:1268]: (error) Dangerous iterator usage.
Date: Thu, 27 Jan 2011 00:40:06 -0800 (PST)

Consider the enclosed program. It reads data from a map and increase the
iterator by one position. If the data just read is just before the last, the
last is destroyed. Yet upon next read, the data returned is the one just
destroyed!

It seems that mixing map.erase() and iterators is unsafe. OTOH, I don't
understand the logic around line 1268: 
 if (is_valid_function (hook_fcn)) result is false, then we erase the next
element ???

I enclose a tentative patchlet to 
1) keep the same logic
2) ensure p is re-initialised to a valid value after map.erase().

Comments ?

Pascal
http://octave.1599824.n4.nabble.com/file/n3241656/testmap.cpp testmap.cpp 
http://octave.1599824.n4.nabble.com/file/n3241656/input.cc.pat input.cc.pat 
-- 
View this message in context: 
http://octave.1599824.n4.nabble.com/src-input-cc-1268-error-Dangerous-iterator-usage-tp3241656p3241656.html
Sent from the Octave - Maintainers mailing list archive at Nabble.com.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]