New Ticket     Tickets     Wiki     Browse Source     Timeline     Roadmap     Ticket Reports     Search

Changeset 81761


Ignore:
Timestamp:
08/04/11 11:08:54 (4 years ago)
Author:
cal@…
Message:

rev-upgrade: Move definition of machista::get_arch_name above typemap free()ing the return value, which would cause a crash

Location:
branches/gsoc11-rev-upgrade/base/src/machista1.0
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/gsoc11-rev-upgrade/base/src/machista1.0/machista.i

    r81757 r81761  
    141141 
    142142/** 
     143 * map macho_get_arch_name() 
     144 * The memory for the returned char * comes from NXGetArchInfoFromCpuType(), 
     145 * which is documentet in arch(3), without ever mentioning any memory issues. I 
     146 * assume it's static memory, that should not be free()'d. 
     147 */ 
     148%rename(get_arch_name) macho_get_arch_name; 
     149const char *macho_get_arch_name(cpu_type_t); 
     150 
     151/** 
    143152 * map macho_format_dylib_version() 
    144153 * Since this function internally allocates the result and returns an allocated 
     
    152161char *macho_format_dylib_version(uint32_t); 
    153162 
    154 /** 
    155  * map macho_get_arch_name() 
    156  * The memory for the returned char * comes from NXGetArchInfoFromCpuType(), 
    157  * which is documentet in arch(3), without ever mentioning any memory issues. I 
    158  * assume it's static memory, that should not be free()'d. 
    159  */ 
    160 %rename(get_arch_name) macho_get_arch_name; 
    161 const char *macho_get_arch_name(cpu_type_t); 
    162  
  • branches/gsoc11-rev-upgrade/base/src/machista1.0/machista_wrap.c

    r81757 r81761  
    22702270 
    22712271SWIGINTERN int 
     2272_wrap_get_arch_name(ClientData clientData SWIGUNUSED, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { 
     2273  cpu_type_t arg1 ; 
     2274  int val1 ; 
     2275  int ecode1 = 0 ; 
     2276  char *result = 0 ; 
     2277   
     2278  if (SWIG_GetArgs(interp, objc, objv,"o:machista::get_arch_name cpu_type_t ",(void *)0) == TCL_ERROR) SWIG_fail; 
     2279  ecode1 = SWIG_AsVal_int SWIG_TCL_CALL_ARGS_2(objv[1], &val1); 
     2280  if (!SWIG_IsOK(ecode1)) { 
     2281    SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "get_arch_name" "', argument " "1"" of type '" "cpu_type_t""'"); 
     2282  }  
     2283  arg1 = (cpu_type_t)(val1); 
     2284  result = (char *)macho_get_arch_name(arg1); 
     2285  Tcl_SetObjResult(interp,SWIG_FromCharPtr((const char *)result)); 
     2286  return TCL_OK; 
     2287fail: 
     2288  return TCL_ERROR; 
     2289} 
     2290 
     2291 
     2292SWIGINTERN int 
    22722293_wrap_format_dylib_version(ClientData clientData SWIGUNUSED, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { 
    22732294  uint32_t arg1 ; 
     
    22832304  arg1 = (uint32_t)(val1); 
    22842305  result = (char *)macho_format_dylib_version(arg1); 
    2285   Tcl_SetObjResult(interp,SWIG_FromCharPtr((const char *)result)); 
    2286   { 
    2287     free(result); 
    2288   } 
    2289   return TCL_OK; 
    2290 fail: 
    2291   return TCL_ERROR; 
    2292 } 
    2293  
    2294  
    2295 SWIGINTERN int 
    2296 _wrap_get_arch_name(ClientData clientData SWIGUNUSED, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { 
    2297   cpu_type_t arg1 ; 
    2298   int val1 ; 
    2299   int ecode1 = 0 ; 
    2300   char *result = 0 ; 
    2301    
    2302   if (SWIG_GetArgs(interp, objc, objv,"o:machista::get_arch_name cpu_type_t ",(void *)0) == TCL_ERROR) SWIG_fail; 
    2303   ecode1 = SWIG_AsVal_int SWIG_TCL_CALL_ARGS_2(objv[1], &val1); 
    2304   if (!SWIG_IsOK(ecode1)) { 
    2305     SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "get_arch_name" "', argument " "1"" of type '" "cpu_type_t""'"); 
    2306   }  
    2307   arg1 = (cpu_type_t)(val1); 
    2308   result = (char *)macho_get_arch_name(arg1); 
    23092306  Tcl_SetObjResult(interp,SWIG_FromCharPtr((const char *)result)); 
    23102307  { 
     
    23402337    { SWIG_prefix "parse_file", (swig_wrapper_func) _wrap_parse_file, NULL}, 
    23412338    { SWIG_prefix "strerror", (swig_wrapper_func) _wrap_strerror, NULL}, 
     2339    { SWIG_prefix "get_arch_name", (swig_wrapper_func) _wrap_get_arch_name, NULL}, 
    23422340    { SWIG_prefix "format_dylib_version", (swig_wrapper_func) _wrap_format_dylib_version, NULL}, 
    2343     { SWIG_prefix "get_arch_name", (swig_wrapper_func) _wrap_get_arch_name, NULL}, 
    23442341    {0, 0, 0} 
    23452342}; 
Note: See TracChangeset for help on using the changeset viewer.