[erlang-patches] integer_to_binary/2 returns incorrect values or crashes with bases other than 10
Fredrik
fredrik@REDACTED
Tue Sep 10 08:49:52 CEST 2013
On 09/09/2013 07:38 PM, Juan Jose Comellas wrote:
> Sorry, there was a mistake in the commit message for the fix I had
> previously sent. I've canceled the original pull request and created a
> new one. The correct branch is in:
>
> git fetch git://github.com/jcomellas/otp.git
> <http://github.com/jcomellas/otp.git> jc-integer-to-binary2_1
>
> https://github.com/jcomellas/otp/compare/erlang:maint...jc-integer-to-binary2_1
> https://github.com/jcomellas/otp/compare/erlang:maint...jc-integer-to-binary2_1.patch
>
>
> On Mon, Sep 9, 2013 at 2:23 PM, Juan Jose Comellas
> <juanjo@REDACTED <mailto:juanjo@REDACTED>> wrote:
>
> The integer_to_binary/2 function works perfectly with base 10
> (because it just calls integer_to_binary/1), but when used with
> other bases it fails when 0 or a negative number are passed as the
> number to convert. e.g.:
>
> 1> integer_to_binary(0, 16).
> <<>>
>
> 2> integer_to_binary(-1, 16).
> ** exception error: bad argument
> in function byte_size/1
> called as byte_size([])
> in call from erlang:integer_to_binary/3
> in call from integer_to_binary/2
>
> The expected results are:
>
> 1> integer_to_binary(0, 16).
> <<"0">>
>
> 2> integer_to_binary(-1, 16).
> <<"-1">>
>
> I've sent this change as a pull request, but on this branch
> there's the patch to fix this problem and some tests to cover
> these cases.
>
> git fetch git://github.com/jcomellas/otp.git
> <http://github.com/jcomellas/otp.git> jc-integer_to_binary2
>
> https://github.com/jcomellas/otp/compare/erlang:maint...jc-integer_to_binary2
> https://github.com/jcomellas/otp/compare/erlang:maint...jc-integer_to_binary2.patch
>
>
>
>
> _______________________________________________
> erlang-patches mailing list
> erlang-patches@REDACTED
> http://erlang.org/mailman/listinfo/erlang-patches
Hello,
The patch will be running in the nightly builds and tests.
Thanks for contributing,
--
BR Fredrik Gustafsson
Erlang OTP Team
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-patches/attachments/20130910/5c8d1607/attachment.htm>
More information about the erlang-patches
mailing list