diff --git a/DESCRIPTION b/DESCRIPTION
index 212a305c94ec428e44aec96788e381cc761c9770..f0adf342367e11c04145793180221ee3152f12ff 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -2,7 +2,7 @@ Package: glpkAPI
 Type: Package
 Title: R Interface to C API of GLPK
 Version: 1.3.1
-Date: 2018-09-03
+Date: 2018-09-13
 Authors@R: c(person("Mayo", "Roettger", email = "mayo.roettger@hhu.de", role = "cre"),
     person("Gabriel", "Gelius-Dietrich", role = "aut", email = "geliudie@uni-duesseldorf.de"),
     person("Louis", "Luangkesorn", email = "lugerpitt@gmail.com", role = "ctb" ))
@@ -13,7 +13,7 @@ SystemRequirements: GLPK (>= 4.42)
 License: GPL-3
 LazyLoad: yes
 Collate: generics.R glpk_ptrClass.R glpk.R glpkAPI.R zzz.R
-Packaged: 2018-09-03 08:30:00 UTC; mayo
+Packaged: 2018-09-13 14:05:00 UTC; mayo
 NeedsCompilation: yes
 Repository: CRAN
-Date/Publication: 2018-09-03 08:30:00
+Date/Publication: 2018-09-13 14:05:00
diff --git a/inst/NEWS.Rd b/inst/NEWS.Rd
index 7553ea025365e895195208d3a86781bffa043211..65f7d13ab107afea15328a934f813bf0a7078477 100644
--- a/inst/NEWS.Rd
+++ b/inst/NEWS.Rd
@@ -5,8 +5,10 @@
 \encoding{UTF-8}
 
 % ---------------------------------------------------------------------------- %
-\section{Changes in version 1.3.1 2018-08-22}{
+\section{Changes in version 1.3.1 2018-09-13}{
   \itemize{
+    \item{fixed a bug where an allocating function was called with an unprotected
+        allocated R object in a makro funtion defined in \file{glpkAPI.h}.}
     \item{changed package maintainer}
   }
 }
diff --git a/src/glpkR.h b/src/glpkR.h
index d8265ff4458e94bc0181b81cdf3bb65da39f65f6..bad42a53d775a14dd68c3c028bf2886bb5fd85a9 100644
--- a/src/glpkR.h
+++ b/src/glpkR.h
@@ -145,7 +145,7 @@
     const int *rm = INTEGER(m); \
     const int *rn = INTEGER(n); \
     oind = R_Calloc(Rf_asInteger(ne), int); \
-    R_orderVector(oind, Rf_asInteger(ne), Rf_lang2(m, n), TRUE, FALSE); \
+    R_orderVector(oind, Rf_asInteger(ne), PROTECT(Rf_lang2(m, n)), TRUE, FALSE); \
     while (y < Rf_asInteger(ne)) { \
         if ( (rm[oind[y-1]] == rm[oind[y]]) && (rn[oind[y-1]] == rn[oind[y]]) ) { \
             dupA = oind[y-1]; \
@@ -158,6 +158,7 @@
     if (dupB) { \
         Rf_error("Duplicate indices 'ia[%i] = ia[%i] = %i' and 'ja[%i] = ja[%i] = %i' not allowed!", dupA+1, dupB+1, rm[dupA], dupA+1, dupB+1, rn[dupB]); \
     } \
+    UNPROTECT(1)
 } while (0)
 #else
 #define checkDupIndices(m, n, ne)