]> git.ipfire.org Git - thirdparty/openldap.git/commitdiff
Fix realloc bug
authorKurt Zeilenga <kurt@openldap.org>
Tue, 6 Nov 2001 17:49:17 +0000 (17:49 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Tue, 6 Nov 2001 17:49:17 +0000 (17:49 +0000)
libraries/liblber/decode.c

index d2fbcdd357176865399775363121f520cc54e5d7..6970826252499b7ddce9625aeb3511667c557bc0 100644 (file)
@@ -585,9 +585,17 @@ ber_scanf ( BerElement *ber,
                            tag != LBER_DEFAULT && rc != LBER_DEFAULT;
                            tag = ber_next_element( ber, &len, last ) )
                        {
+                               void *save = *sss;
+
                                *sss = (char **) LBER_REALLOC( *sss,
                                        (j + 2) * sizeof(char *) );
 
+                               if( *sss == NULL ) {
+                                       LBER_FREE( save );
+                                       rc = LBER_DEFAULT;
+                                       goto breakout;
+                               }
+
                                rc = ber_get_stringa( ber, &((*sss)[j]) );
                                j++;
                        }
@@ -603,9 +611,17 @@ ber_scanf ( BerElement *ber,
                            tag != LBER_DEFAULT && rc != LBER_DEFAULT;
                            tag = ber_next_element( ber, &len, last ) )
                        {
+                               void *save = *bv;
+
                                *bv = (struct berval **) LBER_REALLOC( *bv,
                                        (j + 2) * sizeof(struct berval *) );
                
+                               if( *bv == NULL ) {
+                                       LBER_FREE( save );
+                                       rc = LBER_DEFAULT;
+                                       goto breakout;
+                               }
+
                                rc = ber_get_stringal( ber, &((*bv)[j]) );
                                j++;
                        }
@@ -639,6 +655,7 @@ ber_scanf ( BerElement *ber,
                }
        }
 
+breakout:
        va_end( ap );
 
        if ( rc == LBER_DEFAULT ) {