Tcl Source Code

View Ticket
Login
Ticket UUID: 218419
Title: Error in moving data from c++ to tcl
Type: Bug Created on: 2000-10-26 00:57:20
Submitter: nobody Assigned to: nobody
Subsystem: 12. ByteArray Object Severity:
Priority: 2 Last modified: 2001-04-19 02:57:38
Status: Closed Closed by: dgp
Resolution: Fixed Closed on: 2001-04-18 19:57:38
Version: obsolete: 8.2
Description:
OriginalBugID: 5636 Bug
Version: 8.2
SubmitDate: '2000-05-23'
LastModified: '2000-05-23'
Severity: SER
Status: Closed
Submitter: techsupp
ChangedBy: hobbs
RelatedBugIDs: 3466
OS: Windows NT
OSVersion: NT 4.0 sp 5
Machine: IBM 300PL / Pentium-II 400MHz
FixedDate: '2000-10-25'
ClosedDate: '2000-05-23'


Name:
Hillel Avni

ReproducibleScript:
in c++:
----
int t_mm()
{
char *buf = new char[100];
*(int *) buf = 0xd0800000; //or 0xd0900000 or 0xd0a00000 or 0xd0b00000
Tcl_Obj *t = Tcl_NewObj();
Tcl_AppendToObj (t, buf, 8);
Tcl_SetObjResult(interp, t);
}


in tcl:
---
set a [t_mm]
binary scan $a H* b
puts $b

ObservedBehavior:
input to t_mm, i.e - buf    |   output of tcl
-----------------+-----------
0xd0700000                    |   0xd0700000
0xd0800000                    |   0x00000000
0xd0900000                    |   0x10000000
0xd0a00000                    |   0x20000000
0xd0b00000                    |   0x30000000
0xd0c00000                    |    0xd0c00000

DesiredBehavior:
Same value on both raws.



This is prone to error.  The user should create these byte
arrays with the Tcl_GetByteArrayFromObj and other Tcl ByteArray
C functions to maintain integrity (avoid UTF translation).
Also note the signed int dangers in bug report 3466. 
-- 05/23/2000 hobbs