Skip to content

Commit aa46b9a

Browse files
increment ref count correctly
1 parent 90bee16 commit aa46b9a

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

src/types/circuit.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -324,9 +324,9 @@ pub fn build_circuit_outputs<'ctx>(
324324
let ref_count = entry.extract_value(context, location, outputs, u8_ty, 0)?;
325325
let ref_count_inc = entry.addi(ref_count, k1, location)?;
326326

327-
entry.insert_value(context, location, outputs, ref_count_inc, 0)?;
327+
let output_new = entry.insert_value(context, location, outputs, ref_count_inc, 0)?;
328328

329-
entry.append_operation(func::r#return(&[outputs, outputs], location));
329+
entry.append_operation(func::r#return(&[output_new, output_new], location));
330330

331331
Ok(Some(region))
332332
},
@@ -345,13 +345,7 @@ pub fn build_circuit_outputs<'ctx>(
345345
let k1 = entry.const_int(context, location, 1, 8)?;
346346

347347
let outputs = entry.arg(0)?;
348-
let ref_count = entry.extract_value(
349-
context,
350-
location,
351-
outputs,
352-
u8_ty,
353-
0,
354-
)?;
348+
let ref_count = entry.extract_value(context, location, outputs, u8_ty, 0)?;
355349

356350
// Check that the reference counting is different from 1. If it is equeal to 1, then it is shared.
357351
let is_shared = entry.cmpi(context, CmpiPredicate::Ne, ref_count, k1, location)?;

0 commit comments

Comments
 (0)