Menu

#386 Add NULL check in streamdump.c

1.32.x
closed-fixed
nobody
None
5
2026-06-06
2026-06-05
Steve Grubb
No
There is a missing NULL check. Other functions exit when !nh. In this case, without the '!', if it is not NULL, it returns. If it is NULL it continues to line 75 where it does a NULL dereference and crashes.
---
 src/streamdump.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/streamdump.c b/src/streamdump.c
index b742b0c..3801c12 100644
--- a/src/streamdump.c
+++ b/src/streamdump.c
@@ -70,7 +70,7 @@ void *buf, size_t bufsize )

 static void net123_close_internal(struct net123_handle_struct *nh)
 {

-   if(nh)
+   if(!nh)
        return;
    int *fdp = nh->parts;
 #ifdef WANT_WIN32_SOCKETS

Discussion

  • Thomas Orgis

    Thomas Orgis - 2026-06-05

    Hey, nice bug ID number you got there;-)

    Yeah, this is a glaring error, though the effect is limited to leaking memory and socket descriptors in practice, as the NULL case is hard to construct when this function is only ever called via a pointer stored in the very same handle.

    I confirmed with valgrind that mpg123 --network internal does leak socket data on close when playing a web stream before inverting the bad check, and does not do so anymore when fixing it.

    I'll do the 1.33.6 bugfix release soon, then, I guess. Or maybe 1.34, after all, as there is a change pending that changes build artifacts with cmake.

    Thanks for the heads-up.

     
  • Thomas Orgis

    Thomas Orgis - 2026-06-06
    • status: open --> closed-fixed
     
  • Thomas Orgis

    Thomas Orgis - 2026-06-06

    1.33.6 is out. Thanks.

     

Log in to post a comment.