This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[PATCH] Fix recent fmemopen breakage


Hi,

the last change to fmemopen.c is a bit optimistic, it's not OK to free mem we 
didn't allocate, it may be a static buffer. The patch makes the testsuite 
happy again.

Also included a small linuxthreads warning fix, it may be the wrong solution 
though, cause I find it a bit strange that testandset and __comapare_and_swap 
take differing kind of pointers.

Franz.

	* libio/fmemopen.c (fmemopen_close): Don't free buffer if we didn't allocate 
	it.


	* linuxthreads/spinlock.h: Warning fix.

Index: libio/fmemopen.c
===================================================================
RCS file: /cvs/glibc/libc/libio/fmemopen.c,v
retrieving revision 1.2
diff -u -p -r1.2 fmemopen.c
--- libio/fmemopen.c	2000/09/01 20:49:16	1.2
+++ libio/fmemopen.c	2000/09/02 10:43:20
@@ -183,7 +183,8 @@ fmemopen_close (void *cookie)
 
   c = (fmemopen_cookie_t *) cookie;
 
-  free (c->buffer);
+  if (c->mybuffer)
+    free (c->buffer);
   free (c);
 
   return 0;
Index: linuxthreads/spinlock.h
===================================================================
RCS file: /cvs/glibc/libc/linuxthreads/spinlock.h,v
retrieving revision 1.17
diff -u -p -r1.17 spinlock.h
--- linuxthreads/spinlock.h	2000/08/03 07:16:24	1.17
+++ linuxthreads/spinlock.h	2000/09/02 10:43:20
@@ -49,7 +49,7 @@ static inline int compare_and_swap(long 
 #elif defined(HAS_COMPARE_AND_SWAP)
 
 #ifdef IMPLEMENT_TAS_WITH_CAS
-#define testandset(p) !__compare_and_swap(p, 0, 1)
+#define testandset(p) !__compare_and_swap((long int *) p, 0, 1)
 #endif
 
 #ifdef HAS_COMPARE_AND_SWAP_WITH_RELEASE_SEMANTICS

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]