[PATCH] shm.c: Detect erroneous return value

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[PATCH] shm.c: Detect erroneous return value

Malcolm Smith
void* values always compare as greater than zero, so the return value
from shmat is not properly checked. This caused a segfault for me in a
rather obscure situation.

    Malcolm


--- jack/shm.c.orig     Sun Jul 17 14:27:51 2005
+++ jack/shm.c  Sun Jul 17 14:30:35 2005
@@ -791,7 +791,7 @@
                }
        }
 
-       if ((ri->attached_at = shmat (registry_id, 0, 0)) < 0) {
+       if ((ri->attached_at = shmat (registry_id, 0, 0)) == -1) {
                jack_error ("cannot attach shm registry segment (%s)",
                            strerror (errno));
                return EINVAL;
@@ -824,7 +824,7 @@
                return errno;
        }
 
-       if ((ri->attached_at = shmat (registry_id, 0, 0)) < 0) {
+       if ((ri->attached_at = shmat (registry_id, 0, 0)) == -1) {
                jack_error ("cannot attach shm registry segment (%s)",
                            strerror (errno));
                return EINVAL;
@@ -896,7 +896,7 @@
 jack_attach_shm (jack_shm_info_t* si)
 {
        if ((si->attached_at = shmat (jack_shm_registry[si->index].id,
-                                     0, 0)) < 0) {
+                                     0, 0)) == -1) {
                jack_error ("cannot attach shm segment (%s)",
                            strerror (errno));
                jack_release_shm_info (si->index);


-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. <a href="http://ads.osdn.com/?ad_idt77&alloc_id492&op=click">http://ads.osdn.com/?ad_idt77&alloc_id492&op=click
_______________________________________________
Jackit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jackit-devel