]> git.sur5r.net Git - openldap/blobdiff - libraries/librewrite/var.c
ITS#8585 Fail ldap_result if handle is already bad
[openldap] / libraries / librewrite / var.c
index 0f4b3cf3ee2331a6998eb3db16f215575e6c7450..47ac3a1a6cb873c1760155aa6250fd0f98d8e718 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2000-2008 The OpenLDAP Foundation.
+ * Copyright 2000-2017 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -123,7 +123,11 @@ rewrite_var_replace(
                int flags
 )
 {
-       ber_len_t       len = strlen( value );
+       ber_len_t       len;
+
+       assert( value != NULL );
+
+       len = strlen( value );
 
        if ( var->lv_flags & REWRITE_VAR_COPY_VALUE ) {
                if ( flags & REWRITE_VAR_COPY_VALUE ) {
@@ -151,6 +155,10 @@ rewrite_var_replace(
                }
        }
 
+       if ( var->lv_value.bv_val == NULL ) {
+               return -1;
+       }
+
        var->lv_value.bv_len = len;
 
        return 0;