summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGreg Hudson <ghudson@mit.edu>2012-09-10 12:28:09 -0400
committerGreg Hudson <ghudson@mit.edu>2012-09-10 12:28:09 -0400
commit0633f8317017a7d3ac4ac94c2321d20362f33653 (patch)
tree7adf16e95874f37d64bcac8df78edef4d5835918 /src
parent757860b48bcef42a9a5fddba984607edeb6e205c (diff)
downloadkrb5-0633f8317017a7d3ac4ac94c2321d20362f33653.tar.gz
krb5-0633f8317017a7d3ac4ac94c2321d20362f33653.tar.xz
krb5-0633f8317017a7d3ac4ac94c2321d20362f33653.zip
Add zapfreestr() helper to k5-int.h
Since zapfree(str, strlen(str)) won't work for possibly-null values of str, add a helper zapfreestr() which only calls strlen() if the string value is non-null.
Diffstat (limited to 'src')
-rw-r--r--src/include/k5-int.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/include/k5-int.h b/src/include/k5-int.h
index d119d02be4..670915d741 100644
--- a/src/include/k5-int.h
+++ b/src/include/k5-int.h
@@ -675,6 +675,16 @@ zapfree(void *ptr, size_t len)
}
}
+/* Convenience function: zap and free zero-terminated str if it is non-NULL. */
+static inline void
+zapfreestr(void *str)
+{
+ if (str != NULL) {
+ zap(str, strlen((char *)str));
+ free(str);
+ }
+}
+
/*
* Combine two keys (normally used by the hardware preauth mechanism)
*/