[Title] fix seg-fault in screen shot operation in Windows
authorSon Hyunjun <hj79.son@samsung.com>
Fri, 30 Mar 2012 08:17:44 +0000 (17:17 +0900)
committerSon Hyunjun <hj79.son@samsung.com>
Fri, 30 Mar 2012 08:17:44 +0000 (17:17 +0900)
[Type] Bugfix
[Module]
[Priority] Major
[CQ#]
[Redmine#]
[Problem]
[Cause] MinGW occurs seg fault 'alloca' an array definition using big data.
[Solution] use malloc instead of general array definition.

Change-Id: I8cac6b4aa7d004545b9ef451ae58efcfa5a28c86

tizen/src/skin/maruskin_server.c

index 1d841c5..d5706b2 100644 (file)
@@ -693,7 +693,9 @@ static int send_n( int client_sock, unsigned char* data, int length, int big_dat
     int total_cnt = 0;
 
     int buf_size = big_data ? SEND_BIG_BUF_SIZE : SEND_BUF_SIZE;
-    char databuf[buf_size];
+
+    // use malloc instead of general array definition to avoid seg fault in 'alloca' in MinGW env, only using big buf size.
+    char* databuf = (char*)g_malloc0( buf_size );
 
     INFO( "send_n start. length:%d\n", length );
 
@@ -709,8 +711,8 @@ static int send_n( int client_sock, unsigned char* data, int length, int big_dat
             send_cnt = ( length - total_cnt );
         }
 
-        memset( &databuf, 0, send_cnt );
-        memcpy( &databuf, (char*) ( data + total_cnt ), send_cnt );
+        memset( databuf, 0, send_cnt );
+        memcpy( databuf, (char*) ( data + total_cnt ), send_cnt );
 
         send_cnt = send( client_sock, databuf, send_cnt, 0 );
 
@@ -723,6 +725,8 @@ static int send_n( int client_sock, unsigned char* data, int length, int big_dat
 
     }
 
+    g_free( databuf );
+
     INFO( "send_n finished.\n" );
 
     return total_cnt;