Changeset 2079

Show
Ignore:
Timestamp:
02/25/2008 06:57:32 AM (6 months ago)
Author:
moo
Message:

fixed #1571: Crash when trying to add single item to list in config file

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/lighttpd-1.4.x/src/configparser.y

    r2012 r2079  
    5252} 
    5353 
    54 /* op1 is to be eat/return by this function, op1->key is not cared 
     54/* op1 is to be eat/return by this function if success, op1->key is not cared 
    5555   op2 is left untouch, unreferenced 
    5656 */ 
     
    7070    } else { 
    7171      fprintf(stderr, "data type mismatch, cannot be merge\n"); 
    72       op1->free(op1); 
    7372      return NULL; 
    7473    } 
     
    143142 
    144143varline ::= key(A) ASSIGN expression(B). { 
    145   buffer_copy_string_buffer(B->key, A); 
    146   if (strncmp(A->ptr, "env.", sizeof("env.") - 1) == 0) { 
    147     fprintf(stderr, "Setting env variable is not supported in conditional %d %s: %s\n", 
    148         ctx->current->context_ndx, 
    149         ctx->current->key->ptr, A->ptr); 
    150     ctx->ok = 0; 
    151   } else if (NULL == array_get_element(ctx->current->value, B->key->ptr)) { 
    152     array_insert_unique(ctx->current->value, B); 
    153     B = NULL; 
    154   } else { 
    155     fprintf(stderr, "Duplicate config variable in conditional %d %s: %s\n", 
    156             ctx->current->context_ndx, 
    157             ctx->current->key->ptr, B->key->ptr); 
    158     ctx->ok = 0; 
    159     B->free(B); 
    160     B = NULL; 
     144  if (ctx->ok) { 
     145    buffer_copy_string_buffer(B->key, A); 
     146    if (strncmp(A->ptr, "env.", sizeof("env.") - 1) == 0) { 
     147      fprintf(stderr, "Setting env variable is not supported in conditional %d %s: %s\n", 
     148          ctx->current->context_ndx, 
     149          ctx->current->key->ptr, A->ptr); 
     150      ctx->ok = 0; 
     151    } else if (NULL == array_get_element(ctx->current->value, B->key->ptr)) { 
     152      array_insert_unique(ctx->current->value, B); 
     153      B = NULL; 
     154    } else { 
     155      fprintf(stderr, "Duplicate config variable in conditional %d %s: %s\n", 
     156              ctx->current->context_ndx, 
     157              ctx->current->key->ptr, B->key->ptr); 
     158      ctx->ok = 0; 
     159      B->free(B); 
     160      B = NULL; 
     161    } 
    161162  } 
    162163  buffer_free(A); 
     
    188189    if (NULL == du) { 
    189190      ctx->ok = 0; 
     191      du->free(du); 
    190192    } 
    191193    else {