Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libossaudio ossaudio(3): Plug a fd leak in the new mixer...



details:   https://anonhg.NetBSD.org/src/rev/8676581f5a3a
branches:  trunk
changeset: 977291:8676581f5a3a
user:      nia <nia%NetBSD.org@localhost>
date:      Tue Oct 20 06:53:37 2020 +0000

description:
ossaudio(3): Plug a fd leak in the new mixer API

diffstat:

 lib/libossaudio/ossaudio.c |  11 ++++-------
 1 files changed, 4 insertions(+), 7 deletions(-)

diffs (54 lines):

diff -r f57c76256ec1 -r 8676581f5a3a lib/libossaudio/ossaudio.c
--- a/lib/libossaudio/ossaudio.c        Tue Oct 20 06:43:55 2020 +0000
+++ b/lib/libossaudio/ossaudio.c        Tue Oct 20 06:53:37 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ossaudio.c,v 1.52 2020/10/19 10:28:47 nia Exp $        */
+/*     $NetBSD: ossaudio.c,v 1.53 2020/10/20 06:53:37 nia Exp $        */
 
 /*-
  * Copyright (c) 1997, 2020 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: ossaudio.c,v 1.52 2020/10/19 10:28:47 nia Exp $");
+__RCSID("$NetBSD: ossaudio.c,v 1.53 2020/10/20 06:53:37 nia Exp $");
 
 /*
  * This is an Open Sound System compatibility layer, which provides
@@ -1328,9 +1328,9 @@
                        return newfd;
                mdi.index = ei->ctrl - 1;
                retval = ioctl(newfd, AUDIO_MIXER_DEVINFO, &mdi);
+               tmperrno = errno;
+               close(newfd);
                if (retval < 0) {
-                       tmperrno = errno;
-                       close(newfd);
                        errno = tmperrno;
                        return retval;
                }
@@ -1343,7 +1343,6 @@
                                ei->strindex[i] = noffs;
                                len = strlen(mdi.un.e.member[i].label.name) + 1;
                                if ((noffs + len) >= sizeof(ei->strings)) {
-                                   close(newfd);
                                    errno = ENOMEM;
                                    return -1;
                                }
@@ -1359,7 +1358,6 @@
                                ei->strindex[i] = noffs;
                                len = strlen(mdi.un.s.member[i].label.name) + 1;
                                if ((noffs + len) >= sizeof(ei->strings)) {
-                                   close(newfd);
                                    errno = ENOMEM;
                                    return -1;
                                }
@@ -1369,7 +1367,6 @@
                        }
                        break;
                default:
-                       close(newfd);
                        errno = EINVAL;
                        return -1;
                }



Home | Main Index | Thread Index | Old Index