freetype-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Git][freetype/freetype-demos][master] * src/ftdiff.c (render_state_draw


From: Alexei Podtelezhnikov (@apodtele)
Subject: [Git][freetype/freetype-demos][master] * src/ftdiff.c (render_state_draw), src/common.d (ft_strdup): Clean up.
Date: Sun, 11 Sep 2022 02:19:50 +0000

Alexei Podtelezhnikov pushed to branch master at FreeType / FreeType Demo Programs

Commits:

  • 441c782f
    by Alexei Podtelezhnikov at 2022-09-10T22:18:27-04:00
    * src/ftdiff.c (render_state_draw), src/common.d (ft_strdup): Clean up.
    

2 changed files:

Changes:

  • src/common.c
    ... ... @@ -47,10 +47,10 @@
    47 47
         if ( !str )
    
    48 48
           return NULL;
    
    49 49
     
    
    50
    -    len    = strlen( str );
    
    51
    -    result = (char *)malloc( len + 1 );
    
    50
    +    len    = strlen( str ) + 1;
    
    51
    +    result = (char *)malloc( len );
    
    52 52
         if ( result )
    
    53
    -      memcpy( result, str, len + 1 );
    
    53
    +      memcpy( result, str, len );
    
    54 54
     
    
    55 55
         return result;
    
    56 56
       }
    

  • src/ftdiff.c
    ... ... @@ -509,20 +509,20 @@
    509 509
             return -1;
    
    510 510
     
    
    511 511
           {
    
    512
    -        unsigned int  len = strlen( filepath );
    
    512
    +        unsigned int  len = strlen( filepath ) + 1;
    
    513 513
             char*         p;
    
    514 514
     
    
    515 515
     
    
    516
    -        if ( len + 1 > sizeof ( state->filepath0 ) )
    
    516
    +        if ( len > sizeof ( state->filepath0 ) )
    
    517 517
             {
    
    518
    -          state->filepath = (const char*)malloc( len + 1 );
    
    518
    +          state->filepath = (const char*)malloc( len );
    
    519 519
               if ( state->filepath == NULL )
    
    520 520
               {
    
    521 521
                 state->filepath = state->filepath0;
    
    522 522
                 return -1;
    
    523 523
               }
    
    524 524
             }
    
    525
    -        memcpy( (char*)state->filepath, filepath, len + 1 );
    
    525
    +        memcpy( (char*)state->filepath, filepath, len );
    
    526 526
             p = (char*)strrchr( state->filepath, '\\' );
    
    527 527
             if ( p == NULL )
    
    528 528
               p = (char*)strrchr( state->filepath, '/' );
    


  • reply via email to

    [Prev in Thread] Current Thread [Next in Thread]