Check for malloc(0) to make AIX happy
Prompted by [HEIMDAL-646] by Anton Lundin
This commit is contained in:
@@ -73,7 +73,9 @@ lookup(const char *name)
|
||||
size_t norm_len = u_len * 2;
|
||||
uint32_t *norm = malloc(norm_len * sizeof(uint32_t));
|
||||
|
||||
if (u == NULL || norm == NULL)
|
||||
if (u == NULL && u_len != 0)
|
||||
errx(1, "malloc failed");
|
||||
if (norm == NULL && norm_len != 0)
|
||||
errx(1, "malloc failed");
|
||||
|
||||
ret = wind_utf8ucs4(name, u, &u_len);
|
||||
|
@@ -280,6 +280,11 @@ _wind_stringprep_normalize(const uint32_t *in, size_t in_len,
|
||||
uint32_t *tmp;
|
||||
int ret;
|
||||
|
||||
if (in_len == 0) {
|
||||
*out_len = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
tmp_len = in_len * 4;
|
||||
if (tmp_len < MAX_LENGTH_CANON)
|
||||
tmp_len = MAX_LENGTH_CANON;
|
||||
|
@@ -58,10 +58,16 @@ wind_stringprep(const uint32_t *in, size_t in_len,
|
||||
wind_profile_flags flags)
|
||||
{
|
||||
size_t tmp_len = in_len * 3;
|
||||
uint32_t *tmp = malloc(tmp_len * sizeof(uint32_t));
|
||||
uint32_t *tmp;
|
||||
int ret;
|
||||
size_t olen;
|
||||
|
||||
if (in_len == 0) {
|
||||
*out_len = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
tmp = malloc(tmp_len * sizeof(uint32_t));
|
||||
if (tmp == NULL)
|
||||
return ENOMEM;
|
||||
|
||||
|
@@ -64,7 +64,7 @@ try(const struct example *c)
|
||||
int ret;
|
||||
size_t out_len = c->out_len;
|
||||
uint32_t *tmp = malloc(out_len * sizeof(uint32_t));
|
||||
if (tmp == NULL)
|
||||
if (tmp == NULL && out_len != 0)
|
||||
err(1, "malloc");
|
||||
ret = _wind_stringprep_map(c->in, c->in_len, tmp, &out_len, WIND_PROFILE_NAME);
|
||||
if (ret) {
|
||||
|
@@ -101,7 +101,7 @@ test(char *buf)
|
||||
|
||||
norm_len = MAX_LENGTH_CANON;
|
||||
tmp = malloc(norm_len * sizeof(size_t));
|
||||
if (tmp == NULL)
|
||||
if (tmp == NULL && norm_len != 0)
|
||||
err(1, "malloc");
|
||||
ret = _wind_stringprep_normalize(in, in_len, tmp, &norm_len);
|
||||
if (ret) {
|
||||
|
Reference in New Issue
Block a user