Skip to content

Commit

Permalink
return required length if the given buffer is too small
Browse files Browse the repository at this point in the history
  • Loading branch information
RaphiaRa committed Feb 11, 2025
1 parent b963c93 commit 9582245
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion spms.c
Original file line number Diff line number Diff line change
Expand Up @@ -722,8 +722,10 @@ spms_err spms_sub_read_msg(spms_sub *ring, void *addr, size_t *len, struct spms_
spms_err ret = spms_sub_get_read_buf(ring, &ptr, &ptr_len, info, timeout_ms);
if (ret != SPMS_ERR_OK)
return ret;
if (ptr_len > *len)
if (ptr_len > *len) {
*len = ptr_len;
return SPMS_ERR_INVALID_ARG;
}

memcpy(addr, ptr, ptr_len);
if (spms_sub_finalize_read(ring) == 0)
Expand Down

0 comments on commit 9582245

Please sign in to comment.