asn1_remove_charstring or asn1_remove_octetstring. This means we do
the same thing no matter whether the system returns NULL for malloc(0) or not.
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@4376
dc483132-0cff-0310-8789-
dd5450dbe970
+Thu Sep 29 14:26:34 1994 Theodore Y. Ts'o (tytso@dcl)
+
+ * asn1buf.c (asn1buf_remove_octetstring, asn1buf_remove_charstring):
+ If the length is zero, don't call calloc(0,1); instead
+ return a NULL pointer. This way, we get consistent
+ behavior even on systems where malloc(0) returns a
+ non-null pointer.
+
Tue Sep 27 23:31:50 1994 Theodore Y. Ts'o (tytso@dcl)
* krb5_encode.c (encode_krb5_enc_kdc_rep_part): = should have been
int i;
if(buf->next + len - 1 > buf->bound) return ASN1_OVERRUN;
+ if (len == 0) {
+ *s = 0;
+ return 0;
+ }
*s = (asn1_octet*)calloc(len,sizeof(asn1_octet));
- if((*s == NULL) && len) return ENOMEM;
+ if (*s == NULL)
+ return ENOMEM;
for(i=0; i<len; i++)
(*s)[i] = (asn1_octet)(buf->next)[i];
buf->next += len;
{
int i;
- if(buf->next + len - 1 > buf->bound) return ASN1_OVERRUN;
+ if (buf->next + len - 1 > buf->bound) return ASN1_OVERRUN;
+ if (len == 0) {
+ *s = 0;
+ return 0;
+ }
*s = (char*)calloc(len,sizeof(char));
- if((*s == NULL) && len) return ENOMEM;
+ if (*s == NULL) return ENOMEM;
for(i=0; i<len; i++)
(*s)[i] = (char)(buf->next)[i];
buf->next += len;