Changeset 13c37ad in rtems


Ignore:
Timestamp:
Nov 23, 2009, 9:56:50 PM (10 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, master
Children:
de87499
Parents:
8a68b60
Message:

2009-11-23 Joel Sherrill <joel.sherrill@…>

  • libmisc/shell/shell.c: Always duplicate the environment passed to us because we will delete it when the shell exits. If we do not duplicate it, we could end up freeing memory which was not allocated from the heap or double freeing it.
Location:
cpukit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • cpukit/ChangeLog

    r8a68b60 r13c37ad  
     12009-11-23      Joel Sherrill <joel.sherrill@oarcorp.com>
     2
     3        * libmisc/shell/shell.c: Always duplicate the environment passed to us
     4        because we will delete it when the shell exits. If we do not
     5        duplicate it, we could end up freeing memory which was not allocated
     6        from the heap or double freeing it.
     7
    182009-11-23      Joel Sherrill <joel.sherrill@oarcorp.com>
    29
  • cpukit/libmisc/shell/shell.c

    r8a68b60 r13c37ad  
    6363 */
    6464rtems_shell_env_t *rtems_shell_init_env(
    65   rtems_shell_env_t *shell_env
     65  rtems_shell_env_t *shell_env_p
    6666)
    6767{
    68   if ( !shell_env ) {
    69     shell_env = malloc(sizeof(rtems_shell_env_t));
    70     if ( !shell_env )
    71       return NULL;
     68  rtems_shell_env_t *shell_env;
     69
     70  shell_env = malloc(sizeof(rtems_shell_env_t));
     71  if ( !shell_env )
     72    return NULL;
     73  if ( !shell_env_p ) {
    7274    *shell_env = rtems_global_shell_env;
    73     shell_env->taskname = NULL;
    74   }
     75  } else {
     76    *shell_env = *shell_env_p;
     77  }
     78  shell_env->taskname = NULL;
    7579
    7680  return shell_env;
Note: See TracChangeset for help on using the changeset viewer.