A data-processing pipeline has reported that sensor readings become corrupted after frame duplication. The issue appears only when SensorFrame objects are copied. A minimal reproduction has been provided.
Your task is to investigate why the corruption occurs, identify the underlying ownership flaw, and update the class implementation so copied frames operate independently.
After your fix:
Modifying one frame must not affect another
Frames must maintain isolated storage
Behavior must be deterministic and free of corruption
Program Flow:
Read 8 bytes
Construct frame A
Create frame B as a copy of A
Modify B at index 3
Print A
Print B
Before fixing the class:
A and B both reflect the modification.
After fixing the class:
Only B reflects the modification; A must remain unchanged.
Example Input:
1 2 3 4 5 6 7 8
Example Output (After Fix):
1 2 3 4 5 6 7 8
1 2 3 99 5 6 7 8
Constraints:
The class must be corrected to ensure safe and independent behavior when copied