[issue19638] dtoa: conversion from '__int64' to 'int', possible loss of data

Mark Dickinson report at bugs.python.org
Sat Nov 23 21:08:24 CET 2013


Mark Dickinson added the comment:

Christian:  I don't think this code is safe:

-    nd0 = nd = s - s1;
+    tmp = s - s1;
+    nd0 = nd = Py_SAFE_DOWNCAST(tmp, Py_SSIZE_T, int);

The result of the Py_SAFE_DOWNCAST could be almost anything, and in particular could be negative.  It would take a careful examination of the code to guarantee that a negative nd or nd0 won't lead to difficulties further down the algorithm.  I think we need to raise an error if tmp is too large, *before* the downcast.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue19638>
_______________________________________


More information about the Python-bugs-list mailing list