[ros-dev] [ros-diffs] [turner] 22683: expand %* to batch file params. b ug: #1629

Brandon Turner turnerb7 at msu.edu
Thu Jun 29 14:51:48 CEST 2006


Murphy, Ged (Bolton) wrote:

>turner at svn.reactos.org wrote:
>
>  
>
>>+    bc->raw_params = malloc(_tcslen(param));
>>+    _tcscpy(bc->raw_params,param);
>>    
>>
>
>Please check the docs, I don't have access to any at the moment, but if I
>recall correctly both strlen and wcslen return the number of chars, not
>including the '/0'.
>
>This will therefore mean we miss off the '/0' for ASCII builds and only have
>half the required space for unicode builds.
>
>Ged.
>
>
>_______________________________________________
>Ros-dev mailing list
>Ros-dev at reactos.org
>http://www.reactos.org/mailman/listinfo/ros-dev
>
>
>  
>
Index: batch.c
===================================================================
--- batch.c    (revision 22683)
+++ batch.c    (working copy)
@@ -275,8 +275,17 @@
     //
     // Allocate enough memory to hold the params and copy them over 
without modifications
     //
-    bc->raw_params = malloc(_tcslen(param));
-    _tcscpy(bc->raw_params,param);
+    bc->raw_params = malloc((_tcslen(param)+1) * sizeof(TCHAR));
+    if (bc->raw_params != NULL)
+    {
+        memset (bc->raw_params, 0, _tcslen(bc->raw_params) * 
sizeof(TCHAR));
+        _tcscpy(bc->raw_params,param);
+    }
+    else
+    {
+        error_out_of_memory();
+        return FALSE;
+    }
 
 #ifdef _DEBUG
     DebugPrintf (_T("Batch: returns TRUE\n"));


look better?

Brandon


More information about the Ros-dev mailing list