~ubuntu-branches/ubuntu/karmic/nss/karmic-updates

« back to all changes in this revision

Viewing changes to mozilla/security/nss/lib/base/arena.c

  • Committer: Bazaar Package Importer
  • Author(s): Chris Coulson
  • Date: 2010-10-04 23:18:57 UTC
  • mfrom: (1.1.12 upstream)
  • Revision ID: james.westby@ubuntu.com-20101004231857-grfx62qbg6gknih1
Tags: 3.12.8-0ubuntu0.9.10.1
* New upstream release v3.12.8 (NSS_3_12_8_RTM)
  - Fix browser wildcard certificate validation issue
  - Update root certs
  - Fix SSL deadlocks
* Refresh patches:
  - update debian/patches/38_kbsd.patch
  - update debian/patches/97_SSL_RENEGOTIATE_TRANSITIONAL.patch
* Bump minimum nspr version to 4.8.6
  - update debian/control
* Add new API to symbols file
  - update debian/libnss3-1d.symbols

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
 * ***** END LICENSE BLOCK ***** */
36
36
 
37
37
#ifdef DEBUG
38
 
static const char CVS_ID[] = "@(#) $RCSfile: arena.c,v $ $Revision: 1.12 $ $Date: 2008/05/13 01:22:35 $";
 
38
static const char CVS_ID[] = "@(#) $RCSfile: arena.c,v $ $Revision: 1.13 $ $Date: 2010/03/15 08:29:31 $";
39
39
#endif /* DEBUG */
40
40
 
41
41
/*
1026
1026
  PRUint32 newSize
1027
1027
)
1028
1028
{
 
1029
  NSSArena *arena;
1029
1030
  struct pointer_header *h, *new_h;
1030
1031
  PRUint32 my_newSize = newSize + sizeof(struct pointer_header);
1031
1032
  void *rv;
1051
1052
    return pointer;
1052
1053
  }
1053
1054
 
1054
 
  if( (NSSArena *)NULL == h->arena ) {
 
1055
  arena = h->arena;
 
1056
  if (!arena) {
1055
1057
    /* Heap */
1056
1058
    new_h = (struct pointer_header *)PR_Calloc(1, my_newSize);
1057
1059
    if( (struct pointer_header *)NULL == new_h ) {
1080
1082
    void *p;
1081
1083
    /* Arena */
1082
1084
#ifdef NSSDEBUG
1083
 
    if( PR_SUCCESS != nssArena_verifyPointer(h->arena) ) {
 
1085
    if (PR_SUCCESS != nssArena_verifyPointer(arena)) {
1084
1086
      return (void *)NULL;
1085
1087
    }
1086
1088
#endif /* NSSDEBUG */
1087
1089
 
1088
 
    if( (PRLock *)NULL == h->arena->lock ) {
 
1090
    if (!arena->lock) {
1089
1091
      /* Just got destroyed.. so this pointer is invalid */
1090
1092
      nss_SetError(NSS_ERROR_INVALID_POINTER);
1091
1093
      return (void *)NULL;
1092
1094
    }
1093
 
    PR_Lock(h->arena->lock);
 
1095
    PR_Lock(arena->lock);
1094
1096
 
1095
1097
#ifdef ARENA_THREADMARK
1096
 
    if( (PRThread *)NULL != h->arena->marking_thread ) {
1097
 
      if( PR_GetCurrentThread() != h->arena->marking_thread ) {
1098
 
        PR_Unlock(h->arena->lock);
 
1098
    if (arena->marking_thread) {
 
1099
      if (PR_GetCurrentThread() != arena->marking_thread) {
 
1100
        PR_Unlock(arena->lock);
1099
1101
        nss_SetError(NSS_ERROR_ARENA_MARKED_BY_ANOTHER_THREAD);
1100
1102
        return (void *)NULL;
1101
1103
      }
1117
1119
       */
1118
1120
      char *extra = &((char *)pointer)[ newSize ];
1119
1121
      (void)nsslibc_memset(extra, 0, (h->size - newSize));
1120
 
      PR_Unlock(h->arena->lock);
 
1122
      PR_Unlock(arena->lock);
1121
1123
      return pointer;
1122
1124
    }
1123
1125
 
1124
 
    PR_ARENA_ALLOCATE(p, &h->arena->pool, my_newSize);
 
1126
    PR_ARENA_ALLOCATE(p, &arena->pool, my_newSize);
1125
1127
    if( (void *)NULL == p ) {
1126
 
      PR_Unlock(h->arena->lock);
 
1128
      PR_Unlock(arena->lock);
1127
1129
      nss_SetError(NSS_ERROR_NO_MEMORY);
1128
1130
      return (void *)NULL;
1129
1131
    }
1130
1132
 
1131
1133
    new_h = (struct pointer_header *)p;
1132
 
    new_h->arena = h->arena;
 
1134
    new_h->arena = arena;
1133
1135
    new_h->size = newSize;
1134
1136
    rv = (void *)((char *)new_h + sizeof(struct pointer_header));
1135
1137
    if (rv != pointer) {
1139
1141
    (void)nsslibc_memset(&((char *)rv)[ h->size ], 0, (newSize - h->size));
1140
1142
    h->arena = (NSSArena *)NULL;
1141
1143
    h->size = 0;
1142
 
    PR_Unlock(new_h->arena->lock);
 
1144
    PR_Unlock(arena->lock);
1143
1145
    return rv;
1144
1146
  }
1145
1147
  /*NOTREACHED*/