segfault bug fix

Martin Hosken <[email protected]>
Newsgroups gmane.comp.fonts.fontforge.devel
Message-ID <20131014154751.5d2a5ad2@sil-mh6>
Hi all,

I'm not sure of the best way to submit patches. But I enclose a few short ones inline.

Things I did to get master building on precise. I'm not sure how many are strictly necessary. But I know we don't want to build osx on linux and some inc paths are needed for tests.

diff --git a/Makefile.am b/Makefile.am
index 1f9dd1e..4a2cd21 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -46,7 +46,7 @@ include $(top_srcdir)/mk/layout.am
 
 #--------------------------------------------------------------------------
 
-SUBDIRS = inc libltdl Unicode gutils hotkeys share osx
+SUBDIRS = inc libltdl Unicode gutils hotkeys share 
 
 if LIBZMQ
 SUBDIRS += collab
@@ -66,7 +66,7 @@ SUBDIRS += pyhook
 endif PYTHON_EXTENSION
 
 if MACINTOSH
-SUBDIRS += mackeys
+SUBDIRS += mackeys osx
 endif MACINTOSH
 
 if DESKTOP
diff --git a/configure.ac b/configure.ac
index 05073bc..585a742 100644
--- a/configure.ac
+++ b/configure.ac
@@ -37,8 +37,8 @@ AC_CONFIG_AUX_DIR([config])
 AC_CONFIG_TESTDIR([tests],[fontforge])
 AC_CANONICAL_BUILD
 AC_CANONICAL_HOST
-AC_CONFIG_HEADERS([inc/fontforge-config.h])
-AM_INIT_AUTOMAKE([foreign -Wall])
+AC_CONFIG_HEADER([inc/fontforge-config.h])
+AM_INIT_AUTOMAKE([foreign -Wall subdir-objects])
 AM_MAINTAINER_MODE([enable])
 AC_USE_SYSTEM_EXTENSIONS
 
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 68b8183..eb34f5e 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -48,7 +48,7 @@ TESTSUITE = $(srcdir)/testsuite
 
 # test linking
 link_test_SOURCES = link_test.c
-link_test_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_builddir)/fontforge
+link_test_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/fontforge -I$(top_srcdir)/inc
 link_test_LDADD = $(top_builddir)/fontforge/libfontforge.la
 
 if BUILD_LINK_TEST


And now to the interesting bug which handles a segfault, a key error and tidying up some scaffolding in python.c:

diff --git a/fontforge/cvundoes.c b/fontforge/cvundoes.c
index 3ffdf6c..f118f7e 100644
--- a/fontforge/cvundoes.c
+++ b/fontforge/cvundoes.c
@@ -25,6 +25,7 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "fontforgevw.h"
+#include "views.h"
 #include <math.h>
 #include <ustring.h>
 #include <utype.h>
diff --git a/fontforge/python.c b/fontforge/python.c
index 10201ae..6c02d5e 100644
--- a/fontforge/python.c
+++ b/fontforge/python.c
@@ -18375,8 +18375,10 @@ static PyObject *InitializePythonMainNamespace() {
 static void CreateAllPyModules(void) {
     int i;
 
+    /*
     if (!quiet)
         printf("CreateAllPyModules()\n");
+    */
 
     for ( i=0; i<NUM_MODULES; i++ ) {
         CreatePyModule( all_modules[i] );
@@ -18810,6 +18812,7 @@ return;
     /* (If we loaded from an sfd file) */
     obj = NULL;
     if ( sf->python_persistent!=NULL && PyMapping_Check(sf->python_persistent) &&
+        PyMapping_HasKeyString(sf->python_persistent,"initScriptString") &&
            (obj = PyMapping_GetItemString(sf->python_persistent,"initScriptString"))!=NULL &&
            STRING_CHECK(obj)) {
        char *str = PyBytes_AsString(obj);

Thanks.
Martin

------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60134071&iu=/4140/ostg.clktrk
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.