Changeset 1250 for cacamoo


Ignore:
Timestamp:
Oct 27, 2006, 10:42:52 PM (14 years ago)
Author:
Jean-Yves Lamoureux
Message:
  • Fixed double free in wonderfull perl interpreter
File:
1 edited

Legend:

Unmodified
Added
Removed
  • cacamoo/trunk/src/main.c

    r1246 r1250  
    252252
    253253    /* Import our buffer as an ansi (color) one */
    254     input_buffer = cucul_load_memory(buffer, buffer_size);
     254    input_buffer = cucul_load_memory(buffer, buffer_size-1);
    255255    if(input_buffer == NULL)
    256256    {
     
    265265    }
    266266    /* Export given canvas to format we want */
    267     output_buffer = cucul_export_canvas(canvas, "irc");
     267    output_buffer = cucul_export_canvas(canvas, "ansi");
    268268    if(output_buffer == NULL)
    269269    {
     
    369369    /* AHAHAH, THAT'S A COOL PERL INTERPRETER ! */
    370370    temp2 = replace(temp, " = <<\"EOC\";", "");
    371     if(temp2 != temp)
     371    if(temp!=temp2 && temp2 !=NULL)
    372372    {
    373373        free(temp);
     
    375375    }
    376376    temp2 = replace(temp, " = <<EOC;"    , "");
    377     if(temp2 != temp)
     377    if(temp!=temp2 && temp2 !=NULL)
    378378    {
    379379        free(temp);
     
    381381    }
    382382    temp2 = replace(temp, " = <<EOC"     , "");
    383     if(temp2 != temp)
     383    if(temp!=temp2 && temp2 !=NULL)
    384384    {
    385385        free(temp);
     
    387387    }
    388388    temp2 = replace(temp, " = << EOC"    , "");
    389     if(temp2 != temp)
     389    if(temp!=temp2 && temp2 !=NULL)
    390390    {
    391391        free(temp);
     
    393393    }
    394394    temp2 = replace(temp, "EOC"          , "");
    395     if(temp2 != temp)
     395    if(temp!=temp2 && temp2 !=NULL)
    396396    {
    397397        free(temp);
     
    399399    }
    400400    temp2 = replace(temp, "$eyes"        , cacamoo_use_eyes);
    401     if(temp2 != temp)
     401    if(temp!=temp2 && temp2 !=NULL)
    402402    {
    403403        free(temp);
     
    405405    }
    406406    temp2 = replace(temp, "${eyes}"      , cacamoo_use_eyes);
    407     if(temp2 != temp)
    408     {
    409         free(temp);
    410         temp = temp2;
    411     }
    412 
     407    if(temp!=temp2 && temp2 !=NULL)
     408    {
     409        free(temp);
     410        temp = temp2;
     411    }
    413412    temp2 = replace(temp, "$tongue"      , cacamoo_use_tongue);
    414     if(temp2 != temp)
     413    if(temp!=temp2 && temp2 !=NULL)
    415414    {
    416415        free(temp);
     
    418417    }
    419418    temp2 = replace(temp, "${tongue}"    , cacamoo_use_tongue);
    420     if(temp2 != temp)
    421     {
    422         free(temp);
    423         temp = temp2;
    424     }
    425 
     419    if(temp!=temp2 && temp2 !=NULL)
     420    {
     421        free(temp);
     422        temp = temp2;
     423    }
    426424    temp2 = replace(temp, "$thoughts"    , cacamoo_thoughts);
    427     if(temp2 != temp)
     425    if(temp!=temp2 && temp2 !=NULL)
    428426    {
    429427        free(temp);
     
    431429    }
    432430    temp2 = replace(temp, "${thoughts}"  , cacamoo_thoughts);
    433     if(temp2 != temp)
    434     {
    435         free(temp);
    436         temp = temp2;
    437     }
    438 
     431    if(temp!=temp2 && temp2 !=NULL)
     432    {
     433        free(temp);
     434        temp = temp2;
     435    }
    439436    temp2 = replace(temp, "$the_cow"     , (const char*)string);
    440     if(temp2 != temp)
     437    if(temp!=temp2 && temp2 !=NULL)
    441438    {
    442439        free(temp);
     
    444441    }
    445442    temp2 = replace(temp, "${the_cow}"   , (const char*)string);
    446     if(temp2 != temp)
    447     {
    448         free(temp);
    449         temp = temp2;
    450     }
    451 
     443    if(temp!=temp2 && temp2 !=NULL)
     444    {
     445        free(temp);
     446        temp = temp2;
     447    }
    452448    *size = strlen(temp)+1;
    453449
     
    509505}
    510506
    511 
    512507char *replace(char *str, char *oldpiece, const char *newpiece)
    513508{
     
    554549        if((c = (char *) strstr(str+str_index, oldpiece)) != NULL)
    555550            oldpiece_index = c - str;
    556 
    557 
    558551    }
    559552    /* Copy remaining characters from the right of last matched pattern */
Note: See TracChangeset for help on using the changeset viewer.