fix: placement.rs — actual_col==0 时下溢保护
This commit is contained in:
@@ -34,6 +34,7 @@ pub fn place_data(matrix: &mut Matrix, codewords: &[u8]) {
|
|||||||
if bit_idx >= bits.len() {
|
if bit_idx >= bits.len() {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if actual_col > 0 {
|
||||||
place_bit(
|
place_bit(
|
||||||
matrix,
|
matrix,
|
||||||
(actual_col - 1) as u8,
|
(actual_col - 1) as u8,
|
||||||
@@ -42,6 +43,7 @@ pub fn place_data(matrix: &mut Matrix, codewords: &[u8]) {
|
|||||||
&mut bit_idx,
|
&mut bit_idx,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
for row in 0..size {
|
for row in 0..size {
|
||||||
if bit_idx >= bits.len() {
|
if bit_idx >= bits.len() {
|
||||||
@@ -57,6 +59,7 @@ pub fn place_data(matrix: &mut Matrix, codewords: &[u8]) {
|
|||||||
if bit_idx >= bits.len() {
|
if bit_idx >= bits.len() {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if actual_col > 0 {
|
||||||
place_bit(
|
place_bit(
|
||||||
matrix,
|
matrix,
|
||||||
(actual_col - 1) as u8,
|
(actual_col - 1) as u8,
|
||||||
@@ -66,6 +69,7 @@ pub fn place_data(matrix: &mut Matrix, codewords: &[u8]) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
col -= 2;
|
col -= 2;
|
||||||
going_up = !going_up;
|
going_up = !going_up;
|
||||||
|
|||||||
Reference in New Issue
Block a user