
Edson Tadeu ha escrito:
If the format string have an absolute tabulation (%t), the basic_format::clear() method throws an access violation because of this piece code in format_implementation.hpp(138):
if( bound_.size()==0 || !bound_[ items_[i].argN_ ] )
Here items_[i].argN_ can be negative (defined in internals.hpp(70)), which is an invalid index to bound_[]. I think a simple check of greather than zero would suffice to fix it. Here is a code that catches it:
using boost::format; format f("%0s%-32.32s:%|40t|%|.6|%|55t|%25s\n"); f % "test1" % 2.0 % "test3"; f % "test4" % 5.0 % "test6"; // calls clear() and breaks
Hello Edson, The test case you propose doesn't call clear() nor shows the error you refer to: instead, a boost::io::too_many_args is thrown. Am I missing something? Anyway, seems like you spotted a real problem, and the following does actually call bound_[ items_[i].argN_ ] with items_[i].argN_ negative inside basic_format::clear(), at least for the Boost.Format code in the CVS trunk: format f("%40t%1%"); int x=0; f.bind_arg(1,x); f.clear(); Can you also observe a crash with this snippet? If so, I can try to propose and commit a fix following your suggestion of adding a positiveness check in the offending if. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo