Skip to content

Commit

Permalink
Empty strings are NULL, not ""
Browse files Browse the repository at this point in the history
Because the old API returns "", not NULL.  We have to go fix
that, too
  • Loading branch information
alandekok committed Apr 15, 2015
1 parent 5823183 commit baafa84
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/main/xlat.c
Expand Up @@ -2044,7 +2044,7 @@ static char *xlat_aprint(TALLOC_CTX *ctx, REQUEST *request, xlat_exp_t const * c
char *str = NULL, *child;
char const *p;

XLAT_DEBUG("%.*sxlat aprint %d", lvl, xlat_spaces, node->type);
XLAT_DEBUG("%.*sxlat aprint %d %s", lvl, xlat_spaces, node->type, node->fmt);

switch (node->type) {
/*
Expand Down Expand Up @@ -2266,13 +2266,25 @@ static char *xlat_aprint(TALLOC_CTX *ctx, REQUEST *request, xlat_exp_t const * c
rad_assert(node->alternate != NULL);

str = xlat_aprint(ctx, request, node->child, escape, escape_ctx, lvl);
if (str) break;
if (str) {
XLAT_DEBUG("ALTERNATE got string: %s", str);
break;
}

XLAT_DEBUG("ALTERNATE going to alternate");
str = xlat_aprint(ctx, request, node->alternate, escape, escape_ctx, lvl);
break;

}

/*
* If there's no data, return that, instead of an empty string.
*/
if (str && !str[0]) {
talloc_free(str);
return NULL;
}

/*
* Escape the non-literals we found above.
*/
Expand Down

0 comments on commit baafa84

Please sign in to comment.