Mercurial > projects > ddmd
comparison dmd/backend/iasm.d @ 5:63623152e82a
Fixed memory corruption bug which was introduced when attempting to restore GC functionality
author | dkoroskin <> |
---|---|
date | Tue, 08 Dec 2009 21:39:17 +0300 |
parents | d706d958e4e8 |
children | 2cc604139636 |
comparison
equal
deleted
inserted
replaced
4:d706d958e4e8 | 5:63623152e82a |
---|---|
43 | 43 |
44 import core.memory; | 44 import core.memory; |
45 | 45 |
46 import core.stdc.stdio : printf; | 46 import core.stdc.stdio : printf; |
47 import core.stdc.string : strlen; | 47 import core.stdc.string : strlen; |
48 import core.stdc.stdlib : realloc; | |
48 import core.stdc.limits; | 49 import core.stdc.limits; |
49 | 50 |
50 import std.bitmanip; | 51 import std.bitmanip; |
51 | 52 |
52 alias int[10] jmp_buf; | 53 alias int[10] jmp_buf; |
1870 ubyte* q; | 1871 ubyte* q; |
1871 | 1872 |
1872 if (usBytes+usSize > usMaxbytes) | 1873 if (usBytes+usSize > usMaxbytes) |
1873 { | 1874 { |
1874 usMaxbytes = usBytes + usSize + 10; | 1875 usMaxbytes = usBytes + usSize + 10; |
1875 c.IEV1.as.bytes = cast(char*)GC.realloc(c.IEV1.as.bytes,usMaxbytes); | 1876 c.IEV1.as.bytes = cast(char*)realloc(c.IEV1.as.bytes,usMaxbytes); |
1876 } | 1877 } |
1877 switch (tok_value) | 1878 switch (tok_value) |
1878 { | 1879 { |
1879 case TOK.TOKint32v: | 1880 case TOK.TOKint32v: |
1880 dt.ul = asmtok.int32value; | 1881 dt.ul = asmtok.int32value; |
1930 q = cast(ubyte*)asmtok.ustring; | 1931 q = cast(ubyte*)asmtok.ustring; |
1931 L3: | 1932 L3: |
1932 if (len) | 1933 if (len) |
1933 { | 1934 { |
1934 usMaxbytes += len * usSize; | 1935 usMaxbytes += len * usSize; |
1935 c.IEV1.as.bytes = cast(char*)GC.realloc(c.IEV1.as.bytes,usMaxbytes); | 1936 c.IEV1.as.bytes = cast(char*)realloc(c.IEV1.as.bytes,usMaxbytes); |
1936 memcpy(c.IEV1.as.bytes + usBytes,asmtok.ustring,len); | 1937 memcpy(c.IEV1.as.bytes + usBytes,asmtok.ustring,len); |
1937 | 1938 |
1938 char* p = c.IEV1.as.bytes + usBytes; | 1939 char* p = c.IEV1.as.bytes + usBytes; |
1939 for (size_t i = 0; i < len; i++) | 1940 for (size_t i = 0; i < len; i++) |
1940 { | 1941 { |