assert non-NULL ptrs before calling mem funcs
The definitions of memcpy(), memmove(), and memset() state that the behaviour is undefined if any of the pointer arguments are NULL, and some compilers are known to make use of this to optimise away existing NULL checks in the source. Change-Id: I489bc256e3eac7ff41d91becb0b43aba73dbb3f9 Link: https://www.imperialviolet.org/2016/06/26/nonnull.html
This commit is contained in:

committed by
Jeffrey Altman

parent
d35c9b2d67
commit
190263bb7a
@@ -35,6 +35,7 @@
|
||||
|
||||
#include <heimbasepriv.h>
|
||||
#include <wind.h>
|
||||
#include <assert.h>
|
||||
|
||||
struct PAC_INFO_BUFFER {
|
||||
uint32_t type;
|
||||
@@ -382,6 +383,8 @@ krb5_pac_add_buffer(krb5_context context, krb5_pac p,
|
||||
size_t len, offset, header_end, old_end;
|
||||
uint32_t i;
|
||||
|
||||
assert(data->length > 0 && data->data != NULL);
|
||||
|
||||
len = p->pac->numbuffers;
|
||||
|
||||
ptr = realloc(p->pac,
|
||||
@@ -1101,7 +1104,7 @@ build_logon_name(krb5_context context,
|
||||
krb5_set_error_message(context, ret, "Principal %s is not valid UTF-8", s);
|
||||
free(s);
|
||||
return ret;
|
||||
} else
|
||||
} else
|
||||
free(s);
|
||||
|
||||
s2_len = (ucs2_len + 1) * 2;
|
||||
|
Reference in New Issue
Block a user