From a3fcce8f0ee51d17af83b10a12aacf97545c94b8 Mon Sep 17 00:00:00 2001
From: Lars Kanis <lars@greiz-reinsdorf.de>
Date: Sun, 22 Jan 2012 21:31:40 +0100
Subject: [PATCH] fix invalid memory access in typemap to zero terminated
 FXchar*

noticed at FXComboBox#fillItems
---
 swig-interfaces/ruby-typemaps.i | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/swig-interfaces/ruby-typemaps.i b/swig-interfaces/ruby-typemaps.i
index f0fda1f..d59085d 100644
--- a/swig-interfaces/ruby-typemaps.i
+++ b/swig-interfaces/ruby-typemaps.i
@@ -184,7 +184,7 @@ inline FXbool to_FXbool(VALUE obj){
   $1 = NULL;
   if(!NIL_P($input)){
     Check_Type($input, T_ARRAY);
-    if (FXMALLOC(&$1, FXchar *, RARRAY_LEN($input))+1) {
+    if (FXMALLOC(&$1, FXchar *, RARRAY_LEN($input)+1)) {
       for (long i = 0; i < RARRAY_LEN($input); i++) {
         VALUE e = rb_ary_entry($input, i);
         $1[i] = (FXchar *) StringValuePtr(e);
@@ -201,7 +201,7 @@ inline FXbool to_FXbool(VALUE obj){
   $1 = NULL;
   if(!NIL_P($input)){
     Check_Type($input, T_ARRAY);
-    if (FXMALLOC(&$1, FXColor, RARRAY_LEN($input))+1) {
+    if (FXMALLOC(&$1, FXColor, RARRAY_LEN($input)+1)) {
       for (long i = 0; i < RARRAY_LEN($input); i++) {
         $1[i] = static_cast<FXColor>(NUM2ULONG(rb_ary_entry($input, i)));
       }
@@ -599,7 +599,7 @@ inline void* to_FXEvent(VALUE obj){
 
 /* Output typemap for FXViewport instances */
 %typemap(out) FXViewport {
-    FXViewport* resultptr = new FXViewport($1); 
+    FXViewport* resultptr = new FXViewport($1);
     $result = FXRbGetRubyObj(resultptr, "FXViewport *");
 }
 
@@ -731,7 +731,7 @@ inline void* to_FXEvent(VALUE obj){
  * be able to pass either zero, -1, or a window to that function and get
  * the same behavior as in FOX.
  */
- 
+
 %typemap(in) FXWindow* TOOLBAR_DOCK_AFTER {
     if (TYPE($input) == T_FIXNUM) {
         $1 = reinterpret_cast<FXWindow *>(static_cast<long>(NUM2INT($input)));
-- 
GitLab