Index: nls/msgcat.c =================================================================== --- nls/msgcat.c (revisión: 203174) +++ nls/msgcat.c (copia de trabajo) @@ -89,7 +89,7 @@ static nl_catd load_msgcat(const char *, const char *, const char *); -static pthread_rwlock_t rwlock; +static pthread_rwlock_t rwlock = PTHREAD_RWLOCK_INITIALIZER; struct catentry { SLIST_ENTRY(catentry) list; @@ -135,12 +135,12 @@ /* Try to get it from the cache first */ RLOCK(NLERR); SLIST_FOREACH(np, &cache, list) { - if (strcmp(np->name, name) == 0) { + if ((strcmp(np->name, name) == 0) && (strcmp(np->lang, lang) == 0)) { if (np->caterrno != 0) { /* Found cached failing entry */ UNLOCK; NLRETERR(np->caterrno); - } else if (strcmp(np->lang, lang) == 0) { + } else { /* Found cached successful entry */ np->refcount++; UNLOCK; @@ -325,13 +325,15 @@ /* Remove from cache if not referenced any more */ WLOCK(-1); SLIST_FOREACH(np, &cache, list) { - if ((np->catd->__size == catd->__size) && - memcmp((const void *)np->catd, (const void *)catd, np->catd->__size) == 0) { + if (catd == np->catd) { np->refcount--; if (np->refcount == 0) { munmap(catd->__data, (size_t)catd->__size); free(catd); SLIST_REMOVE(&cache, np, catentry, list); + free(np->name); + free(np->path); + free(np->lang); free(np); } break; @@ -374,8 +376,8 @@ } if (_fstat(fd, &st) != 0) { + _close(fd); SAVEFAIL(name, errno); - _close(fd); return (NLERR); } @@ -390,8 +392,8 @@ if (ntohl((u_int32_t)((struct _nls_cat_hdr *)data)->__magic) != _NLS_MAGIC) { + munmap(data, (size_t)st.st_size); SAVEFAIL(name, errno); - munmap(data, (size_t)st.st_size); NLRETERR(EINVAL); }