libsframe: null check arg before writing to in sframe_encoder_write
Add a null check for the encoded_size argument in sframe_encoder_write to prevent potential crashes.
This patch introduces a null check for the encoded_size argument in the sframe_encoder_write function. Previously, the function would dereference encoded_size unconditionally, which could lead to a crash if a NULL pointer was passed. This change adds a safeguard to prevent such an issue.
In Details
The sframe_encoder_write function in libsframe is responsible for encoding data into the SFrame format. This patch addresses a potential null pointer dereference when the encoded_size output parameter is NULL. The fix ensures that the assignment *encoded_size = 0; is guarded by a check, preventing a crash in cases where the caller does not provide a valid pointer for the encoded size.
- sframe_encoder_write
- A function within the libsframe library responsible for writing encoded data. It takes an encoder context, a pointer to store the encoded size, and an error pointer.
- NULL pointer dereference
- An error that occurs when a program attempts to access a memory address that has not been assigned a valid value (i.e., it points to NULL). This typically results in a program crash.