Skip to content

Commit

Permalink
Reworked fix for #7599: Conversion of text with '\0' to DECFLOAT with…
Browse files Browse the repository at this point in the history
…out errors; ensure better backward compatibility

(cherry picked from commit 3b9d57b)
  • Loading branch information
AlexPeshkoff committed Jun 16, 2023
1 parent 7a0d2a1 commit 6a1311f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
17 changes: 10 additions & 7 deletions src/common/cvt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
#include "../common/dsc_proto.h"
#include "../common/utils_proto.h"
#include "../common/StatusArg.h"
#include "../common/status.h"


#ifdef HAVE_SYS_TYPES_H
Expand Down Expand Up @@ -2083,7 +2084,7 @@ void CVT_move_common(const dsc* from, dsc* to, DecimalStatus decSt, Callbacks* c
}


void CVT_conversion_error(const dsc* desc, ErrorFunction err)
void CVT_conversion_error(const dsc* desc, ErrorFunction err, const Exception* original)
{
/**************************************
*
Expand Down Expand Up @@ -2134,12 +2135,10 @@ void CVT_conversion_error(const dsc* desc, ErrorFunction err)
// Convert to \xDD surely non-printable characters
for (FB_SIZE_T n = 0; n < message.getCount(); ++n)
{
if (message[n] == '\\')
message.insert(n++, 1, '\\');
else if (message[n] < ' ')
if (message[n] < ' ')
{
string hex;
hex.printf("\\x%02x", UCHAR(message[n]));
hex.printf("#x%02x", UCHAR(message[n]));
message.replace(n, 1, hex);
n += (hex.length() - 1);
}
Expand All @@ -2166,7 +2165,11 @@ void CVT_conversion_error(const dsc* desc, ErrorFunction err)
}

//// TODO: Need access to transliterate here to convert message to metadata charset.
err(Arg::Gds(isc_convert_error) << message);
Arg::StatusVector vector;
if (original)
vector.assign(*original);
vector << Arg::Gds(isc_convert_error) << message;
err(vector);
}


Expand Down Expand Up @@ -2986,7 +2989,7 @@ static void checkForIndeterminant(const Exception& e, const dsc* desc, ErrorFunc
StaticStatusVector st;
e.stuffException(st);
if (fb_utils::containsErrorCode(st.begin(), isc_decfloat_invalid_operation))
CVT_conversion_error(desc, err);
CVT_conversion_error(desc, err, &e);
}


Expand Down
2 changes: 1 addition & 1 deletion src/common/cvt.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class Int128;
} // namespace Firebird


void CVT_conversion_error(const dsc*, ErrorFunction);
void CVT_conversion_error(const dsc*, ErrorFunction, const Firebird::Exception* = nullptr);
double CVT_power_of_ten(const int);
SLONG CVT_get_long(const dsc*, SSHORT, Firebird::DecimalStatus, ErrorFunction);
bool CVT_get_boolean(const dsc*, ErrorFunction);
Expand Down

0 comments on commit 6a1311f

Please sign in to comment.