diff options
author | Greg Hudson <ghudson@mit.edu> | 2012-09-10 12:28:09 -0400 |
---|---|---|
committer | Greg Hudson <ghudson@mit.edu> | 2012-09-10 12:28:09 -0400 |
commit | 0633f8317017a7d3ac4ac94c2321d20362f33653 (patch) | |
tree | 7adf16e95874f37d64bcac8df78edef4d5835918 /src/include | |
parent | 757860b48bcef42a9a5fddba984607edeb6e205c (diff) | |
download | krb5-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/include')
-rw-r--r-- | src/include/k5-int.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/include/k5-int.h b/src/include/k5-int.h index d119d02be..670915d74 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) */ |