freetype-commit
[Top][All Lists]
Advanced

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

[freetype2-demos] master 441c782f: * src/ftdiff.c (render_state_draw), s


From: Werner Lemberg
Subject: [freetype2-demos] master 441c782f: * src/ftdiff.c (render_state_draw), src/common.d (ft_strdup): Clean up.
Date: Sat, 10 Sep 2022 22:19:57 -0400 (EDT)

branch: master
commit 441c782f549e0f78c49e93cfb762591ba0d57de3
Author: Alexei Podtelezhnikov <apodtele@gmail.com>
Commit: Alexei Podtelezhnikov <apodtele@gmail.com>

    * src/ftdiff.c (render_state_draw), src/common.d (ft_strdup): Clean up.
---
 src/common.c | 6 +++---
 src/ftdiff.c | 8 ++++----
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/common.c b/src/common.c
index 038bf0f1..693dcad7 100644
--- a/src/common.c
+++ b/src/common.c
@@ -47,10 +47,10 @@
     if ( !str )
       return NULL;
 
-    len    = strlen( str );
-    result = (char *)malloc( len + 1 );
+    len    = strlen( str ) + 1;
+    result = (char *)malloc( len );
     if ( result )
-      memcpy( result, str, len + 1 );
+      memcpy( result, str, len );
 
     return result;
   }
diff --git a/src/ftdiff.c b/src/ftdiff.c
index a50236bd..d3773d57 100644
--- a/src/ftdiff.c
+++ b/src/ftdiff.c
@@ -509,20 +509,20 @@
         return -1;
 
       {
-        unsigned int  len = strlen( filepath );
+        unsigned int  len = strlen( filepath ) + 1;
         char*         p;
 
 
-        if ( len + 1 > sizeof ( state->filepath0 ) )
+        if ( len > sizeof ( state->filepath0 ) )
         {
-          state->filepath = (const char*)malloc( len + 1 );
+          state->filepath = (const char*)malloc( len );
           if ( state->filepath == NULL )
           {
             state->filepath = state->filepath0;
             return -1;
           }
         }
-        memcpy( (char*)state->filepath, filepath, len + 1 );
+        memcpy( (char*)state->filepath, filepath, len );
         p = (char*)strrchr( state->filepath, '\\' );
         if ( p == NULL )
           p = (char*)strrchr( state->filepath, '/' );



reply via email to

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