Rewrite logic in xreset to explicitly look for the empty string instead of leaking all other strings with no content.

This commit is contained in:
Petter Reinholdtsen 2014-04-26 06:57:29 +00:00
parent 511e8c85c6
commit eab869f6b0
2 changed files with 3 additions and 2 deletions

View File

@ -212,7 +212,7 @@ typedef struct creg_struct {
static lsb_t script_inf;
static reg_t reg;
static creg_t creg;
static char empty[1] = "";
char empty[1] = "";
/* Delimeters used for spliting results with strsep(3) */
const char *const delimeter = " ,;\t";

View File

@ -348,8 +348,9 @@ static inline char * xstrdup(const char *restrict s)
return r;
}
extern char empty[];
#define xreset(ptr) \
{char *restrict tmp = (char *restrict)ptr; if (ptr && *tmp) free(ptr);} ptr = NULL
{ if (ptr && empty != ptr) free(ptr);} ptr = NULL
#if defined(HAS_unlinkat) && defined(_ATFILE_SOURCE) && !defined(__stub_unlinkat)
# define xremove(d,x) (__extension__ ({ if ((dryrun ? 0 : \