summaryrefslogtreecommitdiffstats
path: root/librt
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2009-09-05 23:37:40 +0200
committerAustin Foxley <austinf@cetoncorp.com>2009-09-18 11:37:16 -0700
commit7bd16c28e51c92f58f9415ea05dda039df706d5a (patch)
treec0e916ebf2cbc343bd26fa4925141b004e7b0d64 /librt
parent276d3e4e98371c6988f39b3167fe651d6ff3068c (diff)
downloaduClibc-alpine-7bd16c28e51c92f58f9415ea05dda039df706d5a.tar.bz2
uClibc-alpine-7bd16c28e51c92f58f9415ea05dda039df706d5a.tar.xz
do not save/restore errno around free() calls
In any non-buggy program free() does not fail. And when it fails in a buggy program, the failure is usually fatal (heap corruption and segfault). Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com> Signed-off-by: Austin Foxley <austinf@cetoncorp.com>
Diffstat (limited to 'librt')
-rw-r--r--librt/shm.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/librt/shm.c b/librt/shm.c
index f0a974059..dd2132457 100644
--- a/librt/shm.c
+++ b/librt/shm.c
@@ -25,8 +25,8 @@
* Returns a malloc'ed buffer containing the OS specific path
* to the shm filename or NULL upon failure.
*/
-static __attribute_noinline__ char* get_shm_name(const char*name) __nonnull((1));
-static char* get_shm_name(const char*name)
+static __attribute_noinline__ char* get_shm_name(const char *name) __nonnull((1));
+static char* get_shm_name(const char *name)
{
char *path;
int i;
@@ -57,7 +57,7 @@ static char* get_shm_name(const char*name)
int shm_open(const char *name, int oflag, mode_t mode)
{
- int fd, old_errno;
+ int fd;
char *shm_name = get_shm_name(name);
/* Stripped multiple '/' from start; may have set errno properly */
@@ -83,23 +83,19 @@ int shm_open(const char *name, int oflag, mode_t mode)
//}
}
#endif
- old_errno = errno;
- free(shm_name);
- errno = old_errno;
+ free(shm_name); /* doesn't affect errno */
return fd;
}
int shm_unlink(const char *name)
{
char *shm_name = get_shm_name(name);
- int ret, old_errno;
+ int ret;
/* Stripped multiple '/' from start; may have set errno properly */
if (shm_name == NULL)
return -1;
ret = unlink(shm_name);
- old_errno = errno;
- free(shm_name);
- errno = old_errno;
+ free(shm_name); /* doesn't affect errno */
return ret;
}