svn rev #21928: trunk/src/lib/krb5/asn.1/
ghudson@MIT.EDU
ghudson at MIT.EDU
Mon Feb 9 16:25:54 EST 2009
http://src.mit.edu/fisheye/changelog/krb5/?cs=21928
Commit By: ghudson
Log Message:
Make asn1buf_destroy return void, since it's a free function. In
krb5_encode.c functions, make *code well-defined in case of error,
and clean up some memory leaks.
Changed Files:
U trunk/src/lib/krb5/asn.1/asn1buf.c
U trunk/src/lib/krb5/asn.1/asn1buf.h
U trunk/src/lib/krb5/asn.1/krb5_encode.c
Modified: trunk/src/lib/krb5/asn.1/asn1buf.c
===================================================================
--- trunk/src/lib/krb5/asn.1/asn1buf.c 2009-02-09 21:23:00 UTC (rev 21927)
+++ trunk/src/lib/krb5/asn.1/asn1buf.c 2009-02-09 21:25:53 UTC (rev 21928)
@@ -154,14 +154,13 @@
return 0;
}
-asn1_error_code asn1buf_destroy(asn1buf **buf)
+void asn1buf_destroy(asn1buf **buf)
{
if (*buf != NULL) {
free((*buf)->base);
free(*buf);
*buf = NULL;
}
- return 0;
}
#ifdef asn1buf_insert_octet
Modified: trunk/src/lib/krb5/asn.1/asn1buf.h
===================================================================
--- trunk/src/lib/krb5/asn.1/asn1buf.h 2009-02-09 21:23:00 UTC (rev 21927)
+++ trunk/src/lib/krb5/asn.1/asn1buf.h 2009-02-09 21:25:53 UTC (rev 21928)
@@ -129,7 +129,7 @@
constructed indefinite sequence.
effects skips trailing fields. */
-asn1_error_code asn1buf_destroy
+void asn1buf_destroy
(asn1buf **buf);
/* effects Deallocates **buf, sets *buf to NULL. */
Modified: trunk/src/lib/krb5/asn.1/krb5_encode.c
===================================================================
--- trunk/src/lib/krb5/asn.1/krb5_encode.c 2009-02-09 21:23:00 UTC (rev 21927)
+++ trunk/src/lib/krb5/asn.1/krb5_encode.c 2009-02-09 21:25:53 UTC (rev 21928)
@@ -44,7 +44,10 @@
asn1_error_code retval;\
unsigned int length, sum = 0;\
asn1buf *buf=NULL;\
+ krb5_data *tmpcode;\
\
+ *code = NULL;\
+\
if (rep == NULL) return ASN1_MISSING_FIELD;\
\
retval = asn1buf_create(&buf);\
@@ -52,21 +55,19 @@
/* produce the final output and clean up the workspace */
#define krb5_cleanup()\
- retval = asn12krb5_buf(buf,code);\
- if (retval) {\
- asn1buf_destroy(&buf);\
- return retval; }\
- retval = asn1buf_destroy(&buf);\
- if (retval) {\
- return retval; }\
-\
+ retval = asn12krb5_buf(buf,&tmpcode);\
+error:\
+ asn1buf_destroy(&buf);\
+ if (retval)\
+ return retval;\
+ *code = tmpcode;\
return 0
krb5_error_code encode_krb5_pa_pk_as_req(const krb5_pa_pk_as_req *rep, krb5_data **code)
{
krb5_setup();
retval = asn1_encode_pa_pk_as_req(buf,rep,&length);
- if (retval) return retval;
+ if (retval) goto error;
sum += length;
krb5_cleanup();
}
@@ -75,7 +76,7 @@
{
krb5_setup();
retval = asn1_encode_pa_pk_as_req_draft9(buf,rep,&length);
- if (retval) return retval;
+ if (retval) goto error;
sum += length;
krb5_cleanup();
}
@@ -84,7 +85,7 @@
{
krb5_setup();
retval = asn1_encode_pa_pk_as_rep(buf,rep,&length);
- if (retval) return retval;
+ if (retval) goto error;
sum += length;
krb5_cleanup();
}
@@ -93,7 +94,7 @@
{
krb5_setup();
retval = asn1_encode_pa_pk_as_rep_draft9(buf,rep,&length);
- if (retval) return retval;
+ if (retval) goto error;
sum += length;
krb5_cleanup();
}
@@ -102,7 +103,7 @@
{
krb5_setup();
retval = asn1_encode_auth_pack(buf,rep,&length);
- if (retval) return retval;
+ if (retval) goto error;
sum += length;
krb5_cleanup();
}
@@ -111,7 +112,7 @@
{
krb5_setup();
retval = asn1_encode_auth_pack_draft9(buf,rep,&length);
- if (retval) return retval;
+ if (retval) goto error;
sum += length;
krb5_cleanup();
}
@@ -120,7 +121,7 @@
{
krb5_setup();
retval = asn1_encode_kdc_dh_key_info(buf,rep,&length);
- if (retval) return retval;
+ if (retval) goto error;
sum += length;
krb5_cleanup();
}
@@ -129,7 +130,7 @@
{
krb5_setup();
retval = asn1_encode_reply_key_pack(buf,rep,&length);
- if (retval) return retval;
+ if (retval) goto error;
sum += length;
krb5_cleanup();
}
@@ -138,7 +139,7 @@
{
krb5_setup();
retval = asn1_encode_reply_key_pack_draft9(buf,rep,&length);
- if (retval) return retval;
+ if (retval) goto error;
sum += length;
krb5_cleanup();
}
@@ -147,7 +148,7 @@
{
krb5_setup();
retval = asn1_encode_td_trusted_certifiers(buf,rep,&length);
- if (retval) return retval;
+ if (retval) goto error;
sum += length;
krb5_cleanup();
}
@@ -156,7 +157,7 @@
{
krb5_setup();
retval = asn1_encode_sequence_of_typed_data(buf,rep,&length);
- if (retval) return retval;
+ if (retval) goto error;
sum += length;
krb5_cleanup();
}
@@ -165,7 +166,7 @@
{
krb5_setup();
retval = asn1_encode_sequence_of_algorithm_identifier(buf,rep,&length);
- if (retval) return retval;
+ if (retval) goto error;
sum += length;
krb5_cleanup();
}
More information about the cvs-krb5
mailing list