Skip to content

Commit

Permalink
jbuf: better err handling for jbuf_resize()
Browse files Browse the repository at this point in the history
  • Loading branch information
cspiel1 committed Oct 4, 2023
1 parent 97a6d17 commit 3e0668d
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 @@ -303,9 +303,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 3e0668d

Please sign in to comment.