@@ -51,12 +51,18 @@ void FprimeRouter ::dataIn_handler(FwIndexType portNum, Fw::Buffer& packetBuffer
5151 // Copy buffer into a new allocated buffer. This lets us return the original buffer with dataReturnOut,
5252 // and FprimeRouter can handle the deallocation of the file buffer when it returns on fileBufferReturnIn
5353 Fw::Buffer packetBufferCopy = this ->bufferAllocate_out (0 , packetBuffer.getSize ());
54- auto copySerializer = packetBufferCopy.getSerializer ();
55- status = copySerializer.serializeFrom (packetBuffer.getData (), packetBuffer.getSize (),
56- Fw::Serialization::OMIT_LENGTH);
57- FW_ASSERT (status == Fw::FW_SERIALIZE_OK, status);
58- // Send the copied buffer out. It will come back on fileBufferReturnIn once the receiver is done with it
59- this ->fileOut_out (0 , packetBufferCopy);
54+ // Confirm we got a valid buffer before using it
55+ if (packetBufferCopy.isValid ()) {
56+ auto copySerializer = packetBufferCopy.getSerializer ();
57+ status = copySerializer.serializeFrom (packetBuffer.getData (), packetBuffer.getSize (),
58+ Fw::Serialization::OMIT_LENGTH);
59+ FW_ASSERT (status == Fw::FW_SERIALIZE_OK, status);
60+ // Send the copied buffer out. It will come back on fileBufferReturnIn once the receiver is done
61+ // with it
62+ this ->fileOut_out (0 , packetBufferCopy);
63+ } else {
64+ this ->log_WARNING_HI_AllocationError (FprimeRouter_AllocationReason::FILE_UPLINK);
65+ }
6066 }
6167 break ;
6268 }
@@ -67,13 +73,20 @@ void FprimeRouter ::dataIn_handler(FwIndexType portNum, Fw::Buffer& packetBuffer
6773 // Copy buffer into a new allocated buffer. This lets us return the original buffer with dataReturnOut,
6874 // and FprimeRouter can handle the deallocation of the unknown buffer when it returns on bufferReturnIn
6975 Fw::Buffer packetBufferCopy = this ->bufferAllocate_out (0 , packetBuffer.getSize ());
70- auto copySerializer = packetBufferCopy.getSerializer ();
71- status = copySerializer.serializeFrom (packetBuffer.getData (), packetBuffer.getSize (),
72- Fw::Serialization::OMIT_LENGTH);
73- FW_ASSERT (status == Fw::FW_SERIALIZE_OK, status);
74- // Send the copied buffer out. It will come back on fileBufferReturnIn once the receiver is done with it
75- this ->unknownDataOut_out (0 , packetBufferCopy, context);
76+ // Confirm we got a valid buffer before using it
77+ if (packetBufferCopy.isValid ()) {
78+ auto copySerializer = packetBufferCopy.getSerializer ();
79+ status = copySerializer.serializeFrom (packetBuffer.getData (), packetBuffer.getSize (),
80+ Fw::Serialization::OMIT_LENGTH);
81+ FW_ASSERT (status == Fw::FW_SERIALIZE_OK, status);
82+ // Send the copied buffer out. It will come back on fileBufferReturnIn once the receiver is done
83+ // with it
84+ this ->unknownDataOut_out (0 , packetBufferCopy, context);
85+ } else {
86+ this ->log_WARNING_HI_AllocationError (FprimeRouter_AllocationReason::USER_BUFFER);
87+ }
7688 }
89+ break ;
7790 }
7891 }
7992
0 commit comments