]> git.sur5r.net Git - openldap/commitdiff
For ITS#6215: No need to maintain ber->ber_usertag except at ber_printf "!"
authorHallvard Furuseth <hallvard@openldap.org>
Wed, 29 Jul 2009 17:21:54 +0000 (17:21 +0000)
committerHallvard Furuseth <hallvard@openldap.org>
Wed, 29 Jul 2009 17:21:54 +0000 (17:21 +0000)
libraries/liblber/encode.c

index f787e776836d9181ec4a80f5c1af281c4a50f2a4..0514f2f6180cece71adb15a363394b7d2a33f7bc 100644 (file)
@@ -519,10 +519,16 @@ ber_printf( BerElement *ber, LDAP_CONST char *fmt, ... )
                                BEREncodeCallback *f;
                                void *p;
 
+                               ber->ber_usertag = 0;
+
                                f = va_arg( ap, BEREncodeCallback * );
                                p = va_arg( ap, void * );
-
                                rc = (*f)( ber, p );
+
+                               if ( ber->ber_usertag ) {
+                                       ber->ber_usertag = 0;
+                                       goto next;
+                               }
                        } break;
 
                case 'b':       /* boolean */
@@ -579,7 +585,7 @@ ber_printf( BerElement *ber, LDAP_CONST char *fmt, ... )
                case 't':       /* tag for the next element */
                        ber->ber_tag = va_arg( ap, ber_tag_t );
                        ber->ber_usertag = 1;
-                       break;
+                       goto next;
 
                case 'v':       /* vector of strings */
                        if ( (ss = va_arg( ap, char ** )) == NULL )
@@ -636,11 +642,8 @@ ber_printf( BerElement *ber, LDAP_CONST char *fmt, ... )
                        break;
                }
 
-               if ( ber->ber_usertag == 0 ) {
-                       ber->ber_tag = LBER_DEFAULT;
-               } else {
-                       ber->ber_usertag = 0;
-               }
+               ber->ber_tag = LBER_DEFAULT;
+       next:;
        }
 
        va_end( ap );