Code::Blocks Forums

Developer forums (C::B DEVELOPMENT STRICTLY!) => Plugins development => Topic started by: mushakk on June 19, 2007, 12:35:11 pm

Title: Bug in 'source code formatter (AStyle)'
Post by: mushakk on June 19, 2007, 12:35:11 pm
When I try to format generated code (gcc -E) sometimes the plugin crashes :(

Some of the lines in these files are up to 2840 chars!

Thx for your work!
Title: Re: Bug in 'source code formatter (AStyle)'
Post by: dje on June 19, 2007, 01:50:57 pm
Hi !

I think your description is light...
Nightly ? OS? GCC version ? Bug report (*.RPT) ? File that made AStyle crash ?

It would be useful to debug. Don't forget to put the bug on BerliOS !

Dje
Title: Re: Bug in 'source code formatter (AStyle)'
Post by: Ceniza on June 19, 2007, 05:17:43 pm
It would be great if you could provide a sample file that causes the plugin to crash.
Title: Re: Bug in 'source code formatter (AStyle)'
Post by: mushakk on June 20, 2007, 12:09:36 pm
Sorry I'm using yesterday version (20 jun)

With this example file the app crashes.

Quote
Don't forget to put the bug on BerliOS
I'm new here. How can I do that? url for bugs?

[attachment deleted by admin]
Title: Re: Bug in 'source code formatter (AStyle)'
Post by: MortenMacFly on June 20, 2007, 01:21:26 pm
With this example file the app crashes.
That's the culprit (asstreamiterator.h):
Code
  wxChar buffer[2048];
It will result in crashing at line 47 in asstreamiterator.cpp:
Code
  *filterPtr++ = *m_In;
(Notice that filterPtr equals buffer.)
So - you might want to just increase the value in the header to e.g. 4096 and that's basically it.

With regards, Morten.
Title: Re: Bug in 'source code formatter (AStyle)'
Post by: Ceniza on June 20, 2007, 07:37:10 pm
Dynamic allocation seems to be a better choice :)

Fixed and committed :wink:
Title: Re: Bug in 'source code formatter (AStyle)'
Post by: rickg22 on June 20, 2007, 08:24:58 pm
Thanks, Cen! Yes, dynamic allocation is the way to go. Otherwise we'd be hitting buffer overflows everytime someone ends up with a weird file, and we'd do the resizing to 4096,8192, blah blah blah :-P

Thumbs up.
Title: Re: Bug in 'source code formatter (AStyle)'
Post by: mushakk on June 25, 2007, 02:32:23 pm
Thx!

 :D