Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Problem with AnsiString::sprintf in BCB 6.00

154 views
Skip to first unread message

Andreas Osswald

unread,
May 23, 2002, 6:35:47 AM5/23/02
to
Hallo,

we have upgrade our BCB from 5.00 to 6.00. Now we have a big problem with
the function AnsiString::sprintf. If we use empty strings in this function
there is always following Message: EAccessViolation - writing from adress
00000000 !

Sample

String as,as1;
as1 = "";
as.sprintf("%s",as1.c_str()); // here is the Exception

or

as.sprintf("%s",""); // here is the Exception as well
Thanks in advance

Andreas


Remy Lebeau [TeamB]

unread,
May 23, 2002, 4:45:54 PM5/23/02
to
I can reproduce the problem, except that I get an exception at address
FFFFFFFF, not 00000000


Gambit

"Andreas Osswald" <a.os...@ratio-elektronik.de> wrote in message
news:3cecc558_2@dnews...

Andreas Osswald

unread,
May 24, 2002, 2:00:39 AM5/24/02
to
Are we the only one, who use the AnsiString::sprintf function ? All of the
users of BCB 6 must have this problem. Am I rigth the we have to change all
of our Projects to replace the sprintf Function (several mille locations)?
Or is there a quick solution in view ? Or should we give back the BCB 6.0
Version and reconvert to the BCB 5.00 ? What shall we do ?

Andreas

Remy Lebeau [TeamB] <gamb...@yahoo.com> schrieb in im Newsbeitrag:
3ced555d$1_1@dnews...

Remy Lebeau [TeamB]

unread,
May 24, 2002, 3:32:07 AM5/24/02
to
In BCB6? Because I can reproduce the problem every time on mine.


Gambit

"Vladimir Zhuchko" <zhu...@lnr.jinr.ru> wrote in message
news:98qreu4sbsr7cu71a...@4ax.com...

> I am using, without problems.

Vladimir Zhuchko

unread,
May 24, 2002, 3:17:54 AM5/24/02
to
On Fri, 24 May 2002 08:00:39 +0200, "Andreas Osswald"
<a.os...@ratio-elektronik.de> wrote:
I am using, without problems.

With best regards
Vladimir E. Zhuchko

Remy Lebeau [TeamB]

unread,
May 24, 2002, 3:31:19 AM5/24/02
to

"Andreas Osswald" <a.os...@ratio-elektronik.de> wrote in message
news:3cedd659_1@dnews...

> Are we the only one, who use the AnsiString::sprintf function ?

I doubt it, but who knows for sure.

> All of the users of BCB 6 must have this problem.

It wouldn't be the first seemingly obvious bug that made it through the BCB6
testing phases undetected.

> Am I rigth the we have to change all of our Projects to replace the
> sprintf Function (several mille locations)?

Apparently so, at least until a patch can be released. The bug is in
AnsiString itself, it's not something we can fix ourselves as we can't
recompile the VCL.

> Or is there a quick solution in view ? Or should we give back the
> BCB 6.0 Version and reconvert to the BCB 5.00 ? What shall we do ?

In the interim, you can always do something like the following:

AnsiString as, as1;

if(!as1.IsEmpty())
as.sprintf("%s", as1.c_str());
else
as = "";


Gambit

Andrue Cope

unread,
May 24, 2002, 4:40:11 AM5/24/02
to
Andreas Osswald,

> Are we the only one, who use the AnsiString::sprintf function ?
>

We use it a lot..a heck of a lot. We haven't had any problems so far
though (I can reproduce your bug however).

Andrue Cope
[Bicester, UK]

Team Thai Kingdom

Andreas Osswald

unread,
May 24, 2002, 5:57:08 AM5/24/02
to
> Apparently so, at least until a patch can be released. The bug is in
> AnsiString itself, it's not something we can fix ourselves as we can't
> recompile the VCL.

Thanks for your direct answers.
Is there any prognosis possible to say in wich period the patch is coming
out (days/weeks/months)? The point is shall we change over our Projects.

Andreas

Remy Lebeau [TeamB] <gamb...@yahoo.com> schrieb in im Newsbeitrag:

3cedeae9$1_2@dnews...

Remy Lebeau [TeamB]

unread,
May 24, 2002, 12:47:36 PM5/24/02
to
Borland never says anything about time tables. Only "when it's ready" :-)


Gambit

"Andreas Osswald" <a.os...@ratio-elektronik.de> wrote in message

news:3cee0dc9_1@dnews...

Andreas Osswald

unread,
May 27, 2002, 9:27:59 AM5/27/02
to
Hello,

I think my colleague has locate the problem. It is in the AnsiString class
(dstring.cpp) in the function vprintf in line 358:

int _cdecl AnsiString::vprintf(const char* format, va_list paramList)
{
int size = vsprintf(NULL, 0, format, paramList);
SetLength(size);
return vsnprintf(Data, Size + 1, format, paramList);
// in older edition愀 it was:
return vsnprintf(Data, Size, format, paramList); // without +1 in the
Size parameter
}

so if I delete the +1 in vsnprintf and add the dstring.cpp unit to my
project, it works pretty good.

Andreas


Remy Lebeau [TeamB] <gamb...@yahoo.com> schrieb in im Newsbeitrag:

3ced555d$1_1@dnews...

Pete Fraser

unread,
May 27, 2002, 12:30:43 PM5/27/02
to
Are you going to log this in QualityCentral?
Pete

"Andreas Osswald" <a.os...@ratio-elektronik.de> wrote in message

news:3cf233b0_1@dnews...

Andreas Osswald

unread,
May 28, 2002, 1:42:47 AM5/28/02
to
Sorry, but what is the meaning of Quality Central ? Can you explain ?

Andreas


Pete Fraser <pete....@at.frasersoft.dot.net> schrieb in im Newsbeitrag:
3cf25f32$1_2@dnews...


> Are you going to log this in QualityCentral?
> Pete
>
> "Andreas Osswald" <a.os...@ratio-elektronik.de> wrote in message
> news:3cf233b0_1@dnews...
> > Hello,
> >
> > I think my colleague has locate the problem. It is in the AnsiString
class
> > (dstring.cpp) in the function vprintf in line 358:
> >
> > int _cdecl AnsiString::vprintf(const char* format, va_list paramList)
> > {
> > int size = vsprintf(NULL, 0, format, paramList);
> > SetLength(size);
> > return vsnprintf(Data, Size + 1, format, paramList);

> > // in older edition´s it was:

Remy Lebeau [TeamB]

unread,
May 28, 2002, 1:56:04 AM5/28/02
to
Quality Central is the new bug-reporting system Borland recently released
for public use. You can download it from http://qc.borland.com/


Gambit

"Andreas Osswald" <a.os...@ratio-elektronik.de> wrote in message

news:3cf31825_2@dnews...

0 new messages