Graphics: fix handle.tag / gca() / clf() crash 53/18953/3
Clément DAVID [Wed, 25 Jan 2017 11:14:39 +0000 (12:14 +0100)]
my_handle             = scf(100001);
clf(my_handle, "reset");
xdel(winsid())
fig_handle = figure("figure_name", "toto");
//fig_handle = figure("figure_name", "toto");
xdel(winsid())
my_handle             = scf(100001);
clf(my_handle, "reset");

Change-Id: I3f31375ca2c12d84b153d06f86679cd480ae27de

scilab/modules/graphic_objects/src/cpp/ScilabView.cpp
scilab/modules/graphic_objects/src/cpp/createGraphicObject.cpp
scilab/modules/graphics/Makefile.am
scilab/modules/graphics/Makefile.in
scilab/modules/graphics/graphics.vcxproj
scilab/modules/graphics/graphics.vcxproj.filters
scilab/modules/graphics/macros/clf.sci
scilab/modules/graphics/src/cpp/get_tag_property.cpp [moved from scilab/modules/graphics/src/c/getHandleProperty/get_tag_property.c with 86% similarity]

index f18aac2..578ea5f 100644 (file)
@@ -361,7 +361,7 @@ void ScilabView::updateObject(int iUID, int iProperty)
 
                 PathItem* item = (*it).second;
                 item->tag = tag;
-                free(tag);
+                delete[] tag;
             }
             break;
         }
@@ -625,7 +625,7 @@ int ScilabView::search_path(char* _pstPath)
     {
         return 0;
     }
-    
+
     free(pstPath);
     return path->uid;
 }
index 98fd49d..3ace6b4 100644 (file)
@@ -158,6 +158,15 @@ int createFigure(int iDockable, int iMenubarType, int iToolbarType, int iDefault
     {
         int* pUserData = NULL;
         getGraphicObjectProperty(getFigureModel(), __GO_USER_DATA__, jni_int_vector, (void**)&pUserData);
+        if (sizeof(void*) == 4) //32 bits
+        {
+            increaseValRef(NULL, (int*)* (int*)pUserData);
+        }
+        else //64 bits
+        {
+            increaseValRef(NULL, (int*)* (long long*)pUserData);
+        }
+
         setGraphicObjectProperty(id, __GO_USER_DATA__, pUserData, jni_int_vector, iUserDataSize);
     }
 
@@ -167,6 +176,15 @@ int createFigure(int iDockable, int iMenubarType, int iToolbarType, int iDefault
     {
         int* pUserData = NULL;
         getGraphicObjectProperty(getAxesModel(), __GO_USER_DATA__, jni_int_vector, (void**)&pUserData);
+        if (sizeof(void*) == 4) //32 bits
+        {
+            increaseValRef(NULL, (int*)* (int*)pUserData);
+        }
+        else //64 bits
+        {
+            increaseValRef(NULL, (int*)* (long long*)pUserData);
+        }
+
         setGraphicObjectProperty(getCurrentSubWin(), __GO_USER_DATA__, pUserData, jni_int_vector, iUserDataSize);
     }
 
index e498d13..c5498ae 100644 (file)
@@ -172,7 +172,6 @@ GRAPHICS_C_SOURCES = \
     src/c/getHandleProperty/get_outside_colors_property.c \
     src/c/getHandleProperty/get_grid_position_property.c \
     src/c/getHandleProperty/get_anti_aliasing_property.c \
-    src/c/getHandleProperty/get_tag_property.c \
     src/c/getHandleProperty/get_image_type_property.c \
     src/c/getHandleProperty/get_resize_property.c \
     src/c/getHandleProperty/get_toolbar_property.c \
@@ -406,6 +405,7 @@ GRAPHICS_C_SOURCES = \
 
 GRAPHICS_CXX_SOURCES = \
     src/cpp/configgraphicvariable.cpp \
+    src/cpp/get_tag_property.cpp \
     src/cpp/set_data_property.cpp \
     src/cpp/ContourOnMesh.cpp
 
index 8b9c791..97b7cd5 100644 (file)
@@ -320,7 +320,6 @@ am__objects_1 = src/c/libscigraphics_algo_la-GetCommandArg.lo \
        src/c/getHandleProperty/libscigraphics_algo_la-get_outside_colors_property.lo \
        src/c/getHandleProperty/libscigraphics_algo_la-get_grid_position_property.lo \
        src/c/getHandleProperty/libscigraphics_algo_la-get_anti_aliasing_property.lo \
-       src/c/getHandleProperty/libscigraphics_algo_la-get_tag_property.lo \
        src/c/getHandleProperty/libscigraphics_algo_la-get_image_type_property.lo \
        src/c/getHandleProperty/libscigraphics_algo_la-get_resize_property.lo \
        src/c/getHandleProperty/libscigraphics_algo_la-get_toolbar_property.lo \
@@ -553,6 +552,7 @@ am__objects_1 = src/c/libscigraphics_algo_la-GetCommandArg.lo \
        src/c/libscigraphics_algo_la-DllmainGraphics.lo
 am__objects_2 =  \
        src/cpp/libscigraphics_algo_la-configgraphicvariable.lo \
+       src/cpp/libscigraphics_algo_la-get_tag_property.lo \
        src/cpp/libscigraphics_algo_la-set_data_property.lo \
        src/cpp/libscigraphics_algo_la-ContourOnMesh.lo
 am_libscigraphics_algo_la_OBJECTS = $(am__objects_1) $(am__objects_2)
@@ -1170,7 +1170,6 @@ GRAPHICS_C_SOURCES = \
     src/c/getHandleProperty/get_outside_colors_property.c \
     src/c/getHandleProperty/get_grid_position_property.c \
     src/c/getHandleProperty/get_anti_aliasing_property.c \
-    src/c/getHandleProperty/get_tag_property.c \
     src/c/getHandleProperty/get_image_type_property.c \
     src/c/getHandleProperty/get_resize_property.c \
     src/c/getHandleProperty/get_toolbar_property.c \
@@ -1404,6 +1403,7 @@ GRAPHICS_C_SOURCES = \
 
 GRAPHICS_CXX_SOURCES = \
     src/cpp/configgraphicvariable.cpp \
+    src/cpp/get_tag_property.cpp \
     src/cpp/set_data_property.cpp \
     src/cpp/ContourOnMesh.cpp
 
@@ -2176,9 +2176,6 @@ src/c/getHandleProperty/libscigraphics_algo_la-get_grid_position_property.lo:  \
 src/c/getHandleProperty/libscigraphics_algo_la-get_anti_aliasing_property.lo:  \
        src/c/getHandleProperty/$(am__dirstamp) \
        src/c/getHandleProperty/$(DEPDIR)/$(am__dirstamp)
-src/c/getHandleProperty/libscigraphics_algo_la-get_tag_property.lo:  \
-       src/c/getHandleProperty/$(am__dirstamp) \
-       src/c/getHandleProperty/$(DEPDIR)/$(am__dirstamp)
 src/c/getHandleProperty/libscigraphics_algo_la-get_image_type_property.lo:  \
        src/c/getHandleProperty/$(am__dirstamp) \
        src/c/getHandleProperty/$(DEPDIR)/$(am__dirstamp)
@@ -2844,6 +2841,8 @@ src/cpp/$(DEPDIR)/$(am__dirstamp):
        @: > src/cpp/$(DEPDIR)/$(am__dirstamp)
 src/cpp/libscigraphics_algo_la-configgraphicvariable.lo:  \
        src/cpp/$(am__dirstamp) src/cpp/$(DEPDIR)/$(am__dirstamp)
+src/cpp/libscigraphics_algo_la-get_tag_property.lo:  \
+       src/cpp/$(am__dirstamp) src/cpp/$(DEPDIR)/$(am__dirstamp)
 src/cpp/libscigraphics_algo_la-set_data_property.lo:  \
        src/cpp/$(am__dirstamp) src/cpp/$(DEPDIR)/$(am__dirstamp)
 src/cpp/libscigraphics_algo_la-ContourOnMesh.lo:  \
@@ -3318,7 +3317,6 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@src/c/getHandleProperty/$(DEPDIR)/libscigraphics_algo_la-get_surface_color_property.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/c/getHandleProperty/$(DEPDIR)/libscigraphics_algo_la-get_surface_mode_property.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/c/getHandleProperty/$(DEPDIR)/libscigraphics_algo_la-get_tabtitle_property.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@src/c/getHandleProperty/$(DEPDIR)/libscigraphics_algo_la-get_tag_property.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/c/getHandleProperty/$(DEPDIR)/libscigraphics_algo_la-get_text_box_mode_property.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/c/getHandleProperty/$(DEPDIR)/libscigraphics_algo_la-get_text_box_property.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/c/getHandleProperty/$(DEPDIR)/libscigraphics_algo_la-get_text_property.Plo@am__quote@
@@ -3523,6 +3521,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@src/c/getHandleProperty/$(DEPDIR)/libscigraphics_algo_la-set_zoom_state_property.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libscigraphics_algo_la-ContourOnMesh.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libscigraphics_algo_la-configgraphicvariable.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libscigraphics_algo_la-get_tag_property.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libscigraphics_algo_la-set_data_property.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/nographics/$(DEPDIR)/libscigraphics_disable_la-nographics.Plo@am__quote@
 
@@ -4537,13 +4536,6 @@ src/c/getHandleProperty/libscigraphics_algo_la-get_anti_aliasing_property.lo: sr
 @AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscigraphics_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/c/getHandleProperty/libscigraphics_algo_la-get_anti_aliasing_property.lo `test -f 'src/c/getHandleProperty/get_anti_aliasing_property.c' || echo '$(srcdir)/'`src/c/getHandleProperty/get_anti_aliasing_property.c
 
-src/c/getHandleProperty/libscigraphics_algo_la-get_tag_property.lo: src/c/getHandleProperty/get_tag_property.c
-@am__fastdepCC_TRUE@   $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscigraphics_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/c/getHandleProperty/libscigraphics_algo_la-get_tag_property.lo -MD -MP -MF src/c/getHandleProperty/$(DEPDIR)/libscigraphics_algo_la-get_tag_property.Tpo -c -o src/c/getHandleProperty/libscigraphics_algo_la-get_tag_property.lo `test -f 'src/c/getHandleProperty/get_tag_property.c' || echo '$(srcdir)/'`src/c/getHandleProperty/get_tag_property.c
-@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) src/c/getHandleProperty/$(DEPDIR)/libscigraphics_algo_la-get_tag_property.Tpo src/c/getHandleProperty/$(DEPDIR)/libscigraphics_algo_la-get_tag_property.Plo
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='src/c/getHandleProperty/get_tag_property.c' object='src/c/getHandleProperty/libscigraphics_algo_la-get_tag_property.lo' libtool=yes @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscigraphics_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/c/getHandleProperty/libscigraphics_algo_la-get_tag_property.lo `test -f 'src/c/getHandleProperty/get_tag_property.c' || echo '$(srcdir)/'`src/c/getHandleProperty/get_tag_property.c
-
 src/c/getHandleProperty/libscigraphics_algo_la-get_image_type_property.lo: src/c/getHandleProperty/get_image_type_property.c
 @am__fastdepCC_TRUE@   $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscigraphics_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/c/getHandleProperty/libscigraphics_algo_la-get_image_type_property.lo -MD -MP -MF src/c/getHandleProperty/$(DEPDIR)/libscigraphics_algo_la-get_image_type_property.Tpo -c -o src/c/getHandleProperty/libscigraphics_algo_la-get_image_type_property.lo `test -f 'src/c/getHandleProperty/get_image_type_property.c' || echo '$(srcdir)/'`src/c/getHandleProperty/get_image_type_property.c
 @am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) src/c/getHandleProperty/$(DEPDIR)/libscigraphics_algo_la-get_image_type_property.Tpo src/c/getHandleProperty/$(DEPDIR)/libscigraphics_algo_la-get_image_type_property.Plo
@@ -6584,6 +6576,13 @@ src/cpp/libscigraphics_algo_la-configgraphicvariable.lo: src/cpp/configgraphicva
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscigraphics_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o src/cpp/libscigraphics_algo_la-configgraphicvariable.lo `test -f 'src/cpp/configgraphicvariable.cpp' || echo '$(srcdir)/'`src/cpp/configgraphicvariable.cpp
 
+src/cpp/libscigraphics_algo_la-get_tag_property.lo: src/cpp/get_tag_property.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscigraphics_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT src/cpp/libscigraphics_algo_la-get_tag_property.lo -MD -MP -MF src/cpp/$(DEPDIR)/libscigraphics_algo_la-get_tag_property.Tpo -c -o src/cpp/libscigraphics_algo_la-get_tag_property.lo `test -f 'src/cpp/get_tag_property.cpp' || echo '$(srcdir)/'`src/cpp/get_tag_property.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_at)$(am__mv) src/cpp/$(DEPDIR)/libscigraphics_algo_la-get_tag_property.Tpo src/cpp/$(DEPDIR)/libscigraphics_algo_la-get_tag_property.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     $(AM_V_CXX)source='src/cpp/get_tag_property.cpp' object='src/cpp/libscigraphics_algo_la-get_tag_property.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscigraphics_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o src/cpp/libscigraphics_algo_la-get_tag_property.lo `test -f 'src/cpp/get_tag_property.cpp' || echo '$(srcdir)/'`src/cpp/get_tag_property.cpp
+
 src/cpp/libscigraphics_algo_la-set_data_property.lo: src/cpp/set_data_property.cpp
 @am__fastdepCXX_TRUE@  $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscigraphics_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT src/cpp/libscigraphics_algo_la-set_data_property.lo -MD -MP -MF src/cpp/$(DEPDIR)/libscigraphics_algo_la-set_data_property.Tpo -c -o src/cpp/libscigraphics_algo_la-set_data_property.lo `test -f 'src/cpp/set_data_property.cpp' || echo '$(srcdir)/'`src/cpp/set_data_property.cpp
 @am__fastdepCXX_TRUE@  $(AM_V_at)$(am__mv) src/cpp/$(DEPDIR)/libscigraphics_algo_la-set_data_property.Tpo src/cpp/$(DEPDIR)/libscigraphics_algo_la-set_data_property.Plo
index b3c605a..0acd8c8 100644 (file)
@@ -250,6 +250,7 @@ lib /DEF:"$(ProjectDir)elementary_functions_f_Import.def" /SUBSYSTEM:WINDOWS /MA
     <ClCompile Include="sci_gateway\c\sci_color.c" />
     <ClCompile Include="sci_gateway\c\sci_light.c" />
     <ClCompile Include="sci_gateway\c\sci_name2rgb.c" />
+    <ClCompile Include="src\cpp\get_tag_property.cpp" />
     <ClCompile Include="src\cpp\set_data_property.cpp" />
     <ClCompile Include="src\cpp\ContourOnMesh.cpp" />
     <ClCompile Include="src\c\addColor.c" />
@@ -396,7 +397,6 @@ lib /DEF:"$(ProjectDir)elementary_functions_f_Import.def" /SUBSYSTEM:WINDOWS /MA
     <ClCompile Include="src\c\getHandleProperty\get_surface_color_property.c" />
     <ClCompile Include="src\c\getHandleProperty\get_surface_mode_property.c" />
     <ClCompile Include="src\c\getHandleProperty\get_tabtitle_property.c" />
-    <ClCompile Include="src\c\getHandleProperty\get_tag_property.c" />
     <ClCompile Include="src\c\getHandleProperty\get_text_box_mode_property.c" />
     <ClCompile Include="src\c\getHandleProperty\get_text_box_property.c" />
     <ClCompile Include="src\c\getHandleProperty\get_text_property.c" />
@@ -791,4 +791,4 @@ lib /DEF:"$(ProjectDir)elementary_functions_f_Import.def" /SUBSYSTEM:WINDOWS /MA
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <ImportGroup Label="ExtensionTargets">
   </ImportGroup>
-</Project>
\ No newline at end of file
+</Project>
index a802f97..de47351 100644 (file)
     <ClCompile Include="src\c\TerminateGraphics.c">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="src\c\getHandleProperty\get_tag_property.c">
-      <Filter>Source Files</Filter>
-    </ClCompile>
     <ClCompile Include="src\c\getHandleProperty\set_tag_property.c">
       <Filter>Source Files</Filter>
     </ClCompile>
     <ClCompile Include="src\c\getHandleProperty\get_border_property.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="src\cpp\get_tag_property.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
     <ClCompile Include="src\cpp\set_data_property.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
       <Filter>Resource Files</Filter>
     </ResourceCompile>
   </ItemGroup>
-</Project>
\ No newline at end of file
+</Project>
index ee15708..7747abf 100644 (file)
@@ -98,43 +98,43 @@ function clf(varargin)
     // reset figures to default values if needed
     if (job == "reset") then
         defaultFig = gdf();
-        // This literal list should be replaced ASAP with a getproperties(gdf())
+        // This literal list should be replaced with a getproperties(gdf())
         // when such a function will be available:
         allprops = [
-            "children"
-            "figure_position"
-            "figure_size"
-            "axes_size"
-            "auto_resize"
-            "viewport"
-            "figure_name"
-            "figure_id"
-            "info_message"
-            "color_map"
-            "pixel_drawing_mode"
-            "anti_aliasing"
-            "immediate_drawing"
-            "background"
-            "visible"
-            "rotation_style"
-            "event_handler"
-            "event_handler_enable"
-            "user_data"
-            "resizefcn"
-            "closerequestfcn"
-            "resize"
-            "toolbar"
-            "toolbar_visible"
-            "menubar"
-            "menubar_visible"
-            "infobar_visible"
-            "dockable"
-            "layout"
-            "layout_options"
-            "default_axes"
-            "icon"
-            "tag"
-            ];
+        "children"
+        "figure_position"
+        "figure_size"
+        "axes_size"
+        "auto_resize"
+        "viewport"
+        "figure_name"
+        "figure_id"
+        "info_message"
+        "color_map"
+        "pixel_drawing_mode"
+        "anti_aliasing"
+        "immediate_drawing"
+        "background"
+        "visible"
+        "rotation_style"
+        "event_handler"
+        "event_handler_enable"
+        "user_data"
+        "resizefcn"
+        "closerequestfcn"
+        "resize"
+        "toolbar"
+        "toolbar_visible"
+        "menubar"
+        "menubar_visible"
+        "infobar_visible"
+        "dockable"
+        "layout"
+        "layout_options"
+        "default_axes"
+        "icon"
+        "tag"
+        ];
         excluded0 = ["children" "dockable" "menubar" "toolbar" "immediate_drawing"]
         excluded0 = [excluded0 "layout" "layout_options"] // http://bugzilla.scilab.org/14955
         for k = 1: nbHandles
@@ -174,8 +174,8 @@ function yn = isDocked(fh)
     as = matrix(fh.axes_size,2,-1)'
 
     yn = (fh.dockable=="on" & ((fs(:,1)-as(:,1)) > 20)')
-   // A test on vertical dimensions is more complicated, due to switchable
-   // menubar, toolbar and infobar.
+    // A test on vertical dimensions is more complicated, due to switchable
+    // menubar, toolbar and infobar.
     yn = matrix(yn, sf)
 endfunction
 
@@ -1,6 +1,7 @@
 /*
  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
  * Copyright (C) 2011 - DIGITEO - Vincent COUVERT
+ * Copyright (C) 2017 - Scilab Enterprises - Clément DAVID
  *
  * Copyright (C) 2012 - 2016 - Scilab Enterprises
  *
  */
 
 /*------------------------------------------------------------------------*/
-/* file: get_tag_property.c                                               */
+/* file: get_tag_property.cpp                                               */
 /* desc : function to retrieve in Scilab the tag field of                 */
 /*        a handle                                                        */
 /*------------------------------------------------------------------------*/
 
+extern "C"
+{
 #include "sci_types.h"
 #include "getHandleProperty.h"
 #include "returnProperty.h"
@@ -27,6 +30,7 @@
 
 #include "getGraphicObjectProperty.h"
 #include "graphicObjectProperties.h"
+}
 
 /*------------------------------------------------------------------------*/
 void* get_tag_property(void* _pvCtx, int iObjUID)
@@ -34,17 +38,18 @@ void* get_tag_property(void* _pvCtx, int iObjUID)
     char* tag = NULL;
     void* status = NULL;
 
+       // the tag pointer is allocated using new[]
     getGraphicObjectProperty(iObjUID,  __GO_TAG__, jni_string, (void**) &tag);
 
     if (tag == NULL)
     {
         Scierror(999, _("'%s' property does not exist for this handle.\n"), "Tag");
-        return FALSE;
+        return nullptr;
     }
     else
     {
         status = sciReturnString(tag);
-        free(tag);
+        delete[] tag;
         return status;
     }
 }