Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pm_OpenInput needs an additional check #81

Open
mhalog78 opened this issue Jan 24, 2025 · 0 comments
Open

Pm_OpenInput needs an additional check #81

mhalog78 opened this issue Jan 24, 2025 · 0 comments

Comments

@mhalog78
Copy link

I built and ran the 'mm' program. There were no devices connected; 'mm' showed none. I typed '0' for the input device ID. 'mm' crashed:

MIDI input devices:
Type input device number: 0
zsh: segmentation fault  mm

It turns out that Pm_OpenOutput has an extra test that Pm_OpenInput doesn't have.
Here is a diff:

$  diff -u portmidi.c-ORIG portmidi.c
--- portmidi.c-ORIG     2024-12-03 14:03:48
+++ portmidi.c  2025-01-22 14:03:19
@@ -954,7 +954,9 @@
     *stream = NULL;  /* invariant: *stream == midi */
     
     /* arg checking */
-    if (!pm_descriptors[inputDevice].pub.input) 
+    if (inputDevice < 0 || inputDevice >= pm_descriptor_len)
+        err = pmInvalidDeviceId;
+    else if (!pm_descriptors[inputDevice].pub.input) 
         err =  pmInvalidDeviceId;
     else if (pm_descriptors[inputDevice].pub.opened)
         err =  pmInvalidDeviceId;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant