* asn1_decode_k.c: yet another instance of the SunOS realloc bug
authorTom Yu <tlyu@mit.edu>
Sat, 9 Jul 1994 02:29:00 +0000 (02:29 +0000)
committerTom Yu <tlyu@mit.edu>
Sat, 9 Jul 1994 02:29:00 +0000 (02:29 +0000)
* asn1buf.c: whee SunOS realloc of a NULL pointer returns NULL.
sigh.

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@3961 dc483132-0cff-0310-8789-dd5450dbe970

src/lib/krb5/asn.1/ChangeLog
src/lib/krb5/asn.1/asn1_decode_k.c
src/lib/krb5/asn.1/asn1buf.c

index a8d2e3cac07b98c00f4e281d170bd4aae23c1a41..fd722eb15036a2d8570b5271fbcdfe3b90359382 100644 (file)
@@ -1,3 +1,10 @@
+Fri Jul  8 17:32:29 1994  Tom Yu  (tlyu at dragons-lair)
+
+       * asn1_decode_k.c: yet another instance of the SunOS realloc bug
+
+       * asn1buf.c: whee SunOS realloc of a NULL pointer returns NULL.
+       sigh.
+
 Wed Jul  6 13:21:35 1994  Mark Eichin  (eichin@cygnus.com)
 
        * an1buf.c: Harry saves vs. Unix again.  Making sure that anything
index 734d7aa418d7d173243716cf22157461662fd697..3d64d14f7b3e0fe6e2fb08d8372384b1111c6694 100644 (file)
@@ -203,8 +203,11 @@ asn1_error_code asn1_decode_principal_name(DECLARG(asn1buf *, buf),
     { sequence_of(&subbuf);
       while(asn1buf_remains(&seqbuf)){
        size++;
-       (*val)->data = (krb5_data*)realloc((*val)->data,
-                                          size*sizeof(krb5_data));
+       if ((*val)->data == NULL)
+         (*val)->data = (krb5_data*)malloc(size*sizeof(krb5_data));
+       else
+         (*val)->data = (krb5_data*)realloc((*val)->data,
+                                            size*sizeof(krb5_data));
        if((*val)->data == NULL) return ENOMEM;
        retval = asn1_decode_generalstring(&seqbuf,
                                           &((*val)->data[size-1].length),
@@ -490,8 +493,11 @@ if(retval) return retval
      
 #define array_append(array,size,element,type)\
 size++;\
-*(array) = (type**)realloc(*(array),\
-                                 (size+1)*sizeof(type*));\
+if (*(array) == NULL)\
+     *(array) = (type**)malloc((size+1)*sizeof(type*));\
+else\
+  *(array) = (type**)realloc(*(array),\
+                            (size+1)*sizeof(type*));\
 if(*(array) == NULL) return ENOMEM;\
 (*(array))[(size)-1] = elt
      
index cc8cf71156bf2cdd82e1237d21d176fe50d564f9..393014dddf497269a19f329cbcee12d95daa3c0f 100644 (file)
@@ -332,11 +332,15 @@ asn1_error_code asn1buf_expand(DECLARG(asn1buf *, buf),
   if(buf->base == NULL) bound_offset = -1;
   else bound_offset = buf->bound - buf->base;
 
-  
-  buf->base = realloc(buf->base,
-                     (asn1buf_size(buf)+(inc>STANDARD_INCREMENT ?
-                                         inc : STANDARD_INCREMENT))
-                     * sizeof(asn1_octet));
+  if (buf->base == NULL)
+    buf->base = malloc((asn1buf_size(buf)+(inc>STANDARD_INCREMENT ?
+                                          inc : STANDARD_INCREMENT))
+                      * sizeof(asn1_octet));
+  else
+    buf->base = realloc(buf->base,
+                       (asn1buf_size(buf)+(inc>STANDARD_INCREMENT ?
+                                           inc : STANDARD_INCREMENT))
+                       * sizeof(asn1_octet));
   if(buf->base == NULL) return ENOMEM;
   buf->bound = (buf->base) + bound_offset + inc;
   buf->next = (buf->base) + next_offset;