Changeset 1019


Ignore:
Timestamp:
Jan 22, 2004, 4:11:28 AM (22 years ago)
Author:
bird
Message:

Reversed pointer check on malloc result. (buh, bad bad me)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/emx/src/lib/app/setenv.c

    • Property cvs2svn:cvs-rev changed from 1.2 to 1.3
    r1018 r1019  
    1818#include <emx/time.h>           /* _tzset_flag */
    1919
    20            
     20
    2121/**
    2222 * Set environment variable.
     
    2626 * @param   envname     Name of environment variable to set.
    2727 *                      Shall not be NULL, empty string or contain '='.
    28  * @param   envval      The value to set.     
     28 * @param   envval      The value to set.
    2929 * @param   overwrite   If set any existing variable should be overwritten.
    30  *                      If clear return successfully without changing any 
     30 *                      If clear return successfully without changing any
    3131 *                      existing variable.
    32  *                      If there is not existing variable it is added 
     32 *                      If there is not existing variable it is added
    3333 *                      regardless of the state of this flag.
    3434 * @author  knut st. osmundsen <bird-srcspam@anduin.net>
     
    5555
    5656  /* search for existing variable iinstance  */
    57   lenname = strlen (envname);       
     57  lenname = strlen (envname);
    5858  p = environ;
    5959  env_size = 0;
     
    8686        {
    8787          p = malloc ((env_size+2) * sizeof (char *));
    88           if (p == NULL) 
     88          if (p == NULL)
    8989              return -1;
    9090          environ = p;
     
    9595        {
    9696          p = realloc (environ, (env_size+2) * sizeof (char *));
    97           if (p == NULL) 
     97          if (p == NULL)
    9898              return -1;
    9999          environ = p;
     
    107107  /* Allocate space for new variable and assign it. */
    108108  *p = malloc(lenname + lenval + 2);
    109   if (*p)
     109  if (!*p)
    110110    return -1;
    111111  memcpy(*p, envname, lenname);
Note: See TracChangeset for help on using the changeset viewer.