summaryrefslogtreecommitdiff
path: root/pcre_refcount.c
diff options
context:
space:
mode:
authorph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>2011-12-28 17:16:11 +0000
committerph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>2011-12-28 17:16:11 +0000
commit5e8b286b566d7ec502b80892e5b709025631d58c (patch)
treec8a6c83ad13e79a9b64718b784fe0126764d98b7 /pcre_refcount.c
parenta29cc4dc66d82b59de7616c53517c58271e6e0e8 (diff)
downloadpcre-5e8b286b566d7ec502b80892e5b709025631d58c.tar.gz
Merging all the changes from the pcre16 branch into the trunk.
git-svn-id: svn://vcs.exim.org/pcre/code/trunk@836 2f5784b3-3f2a-0410-8824-cb99058d5e15
Diffstat (limited to 'pcre_refcount.c')
-rw-r--r--pcre_refcount.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/pcre_refcount.c b/pcre_refcount.c
index 92e4b85..fdda9e4 100644
--- a/pcre_refcount.c
+++ b/pcre_refcount.c
@@ -6,7 +6,7 @@
and semantics are as close as possible to those of the Perl 5 language.
Written by Philip Hazel
- Copyright (c) 1997-2008 University of Cambridge
+ Copyright (c) 1997-2012 University of Cambridge
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
@@ -68,11 +68,18 @@ Returns: the (possibly updated) count value (a non-negative number), or
a negative error number
*/
+#ifdef COMPILE_PCRE8
PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
pcre_refcount(pcre *argument_re, int adjust)
+#else
+PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
+pcre_refcount(pcre *argument_re, int adjust)
+#endif
{
real_pcre *re = (real_pcre *)argument_re;
if (re == NULL) return PCRE_ERROR_NULL;
+if (re->magic_number != MAGIC_NUMBER) return PCRE_ERROR_BADMAGIC;
+if ((re->flags & PCRE_MODE) == 0) return PCRE_ERROR_BADMODE;
re->ref_count = (-adjust > re->ref_count)? 0 :
(adjust + re->ref_count > 65535)? 65535 :
re->ref_count + adjust;