Skip to content

Commit cc221c4

Browse files
committed
rustc: Don't include a trailing null when writing out metadata; it corrupts the EBML
1 parent 8b59681 commit cc221c4

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/comp/middle/metadata.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,9 @@ fn ty_fn_str(vec[ty.arg] args, @ty.t out, def_str ds) -> str {
145145
}
146146

147147

148-
// Returns a Plain Old LLVM String.
148+
// Returns a Plain Old LLVM String, *without* the trailing zero byte.
149149
fn C_postr(str s) -> ValueRef {
150-
ret llvm.LLVMConstString(_str.buf(s), _str.byte_len(s), False);
150+
ret llvm.LLVMConstString(_str.buf(s), _str.byte_len(s) - 1u, False);
151151
}
152152

153153

@@ -303,8 +303,9 @@ fn encode_tag_id(&ebml.writer ebml_w, &ast.def_id id) {
303303
fn encode_tag_variant_info(@trans.crate_ctxt cx, &ebml.writer ebml_w,
304304
ast.def_id did, vec[ast.variant] variants) {
305305
for (ast.variant variant in variants) {
306-
ebml.start_tag(ebml_w, tag_items_variant);
306+
ebml.start_tag(ebml_w, tag_items_item);
307307
encode_def_id(ebml_w, variant.id);
308+
encode_kind(ebml_w, 'v' as u8);
308309
encode_tag_id(ebml_w, did);
309310
encode_type(ebml_w, trans.node_ann_type(cx, variant.ann));
310311
if (_vec.len[ast.variant_arg](variant.args) > 0u) {
@@ -356,7 +357,7 @@ fn encode_info_for_item(@trans.crate_ctxt cx, &ebml.writer ebml_w,
356357
encode_type_params(ebml_w, tps);
357358
ebml.end_tag(ebml_w);
358359

359-
encode_tag_variant_info(cx, ebml_w, did, variants);
360+
//encode_tag_variant_info(cx, ebml_w, did, variants);
360361
}
361362
case (ast.item_obj(?id, _, ?tps, ?did, ?ann)) {
362363
ebml.start_tag(ebml_w, tag_items_item);

0 commit comments

Comments
 (0)