Skip to content

Commit

Permalink
jbuf: better err handling
Browse files Browse the repository at this point in the history
  • Loading branch information
cspiel1 committed Oct 4, 2023
1 parent 16849a9 commit 2d82a08
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/jbuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -300,9 +300,12 @@ int jbuf_alloc(struct jbuf **jbp, uint32_t min, uint32_t max)
*/
int jbuf_resize(struct jbuf *jb, uint32_t packets)
{
if (packets <= jb->packets)
if (!jb)
return EINVAL;

if (packets <= jb->packets)
return 0;

for (uint32_t i=jb->packets; i<packets; i++) {
struct packet *p = mem_zalloc(sizeof(*p), NULL);
if (!p)
Expand Down

0 comments on commit 2d82a08

Please sign in to comment.