Skip to content

Conversation

@bpintea
Copy link
Collaborator

@bpintea bpintea commented Feb 25, 2019

This PR adds two conversion fixes:

  • on wide to C string conversion, an incorrect truncation was signaled, due to using the original wide string byte count on evaluating the required output buffer size, instead of the converted string byte count.
  • on double conversion to float, the value zero was not considered when checking if the original double is not out of the float range (i.e. 0 < FLT_MIN lead to an error; the range check is required since the double resolution is higher than float's and naturally not all doubles can be converted losslessly to floats; in this check zero is a special case).

In case of SQLWCHAR to SQLCHAR conversion the truncation indication
was wrongly signaled (the conversion was performed correctly, though).
This happened because of the wrong number of bytes compared against
available buffer: the SQLWCHAR string space instead of the (correct)
converted equivalent.
- double zero will be less than FLT_MIN and still a valid float;
- double zero to integers conversions consider this case already and are
not affected.
Copy link
Collaborator

@edsavage edsavage left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@bpintea bpintea merged commit f6669dd into elastic:master Feb 26, 2019
@bpintea bpintea deleted the fix/conversions_str_flt branch February 26, 2019 11:28
bpintea added a commit that referenced this pull request Feb 26, 2019
* fix wide to C string conversion truncation indic.

In case of SQLWCHAR to SQLCHAR conversion the truncation indication
was wrongly signaled (the conversion was performed correctly, though).
This happened because of the wrong number of bytes compared against
available buffer: the SQLWCHAR string space instead of the (correct)
converted equivalent.

* added unit test for the fix

* fix: consider val 0 on dbl to float range check

- double zero will be less than FLT_MIN and still a valid float;
- double zero to integers conversions consider this case already and are
not affected.

(cherry picked from commit f6669dd)
bpintea added a commit that referenced this pull request Feb 26, 2019
* fix wide to C string conversion truncation indic.

In case of SQLWCHAR to SQLCHAR conversion the truncation indication
was wrongly signaled (the conversion was performed correctly, though).
This happened because of the wrong number of bytes compared against
available buffer: the SQLWCHAR string space instead of the (correct)
converted equivalent.

* added unit test for the fix

* fix: consider val 0 on dbl to float range check

- double zero will be less than FLT_MIN and still a valid float;
- double zero to integers conversions consider this case already and are
not affected.

(cherry picked from commit f6669dd)
bpintea added a commit that referenced this pull request Feb 26, 2019
* fix wide to C string conversion truncation indic.

In case of SQLWCHAR to SQLCHAR conversion the truncation indication
was wrongly signaled (the conversion was performed correctly, though).
This happened because of the wrong number of bytes compared against
available buffer: the SQLWCHAR string space instead of the (correct)
converted equivalent.

* added unit test for the fix

* fix: consider val 0 on dbl to float range check

- double zero will be less than FLT_MIN and still a valid float;
- double zero to integers conversions consider this case already and are
not affected.

(cherry picked from commit f6669dd)
bpintea added a commit that referenced this pull request Feb 26, 2019
* fix wide to C string conversion truncation indic.

In case of SQLWCHAR to SQLCHAR conversion the truncation indication
was wrongly signaled (the conversion was performed correctly, though).
This happened because of the wrong number of bytes compared against
available buffer: the SQLWCHAR string space instead of the (correct)
converted equivalent.

* added unit test for the fix

* fix: consider val 0 on dbl to float range check

- double zero will be less than FLT_MIN and still a valid float;
- double zero to integers conversions consider this case already and are
not affected.

(cherry picked from commit f6669dd)
@bpintea bpintea added >bug and removed fix labels May 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants