summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2006-03-29 22:51:23 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 11:15:47 -0500
commit68dcff3f3a4a497a342c18844b57af14912b1570 (patch)
treebf012c10331e28df8384a84cb0f111a3332db2d4 /source3
parente4c66fe4ca2fbc3099009c2efd5cc8f37ed3ec7e (diff)
downloadsamba-68dcff3f3a4a497a342c18844b57af14912b1570.tar.gz
samba-68dcff3f3a4a497a342c18844b57af14912b1570.tar.bz2
samba-68dcff3f3a4a497a342c18844b57af14912b1570.zip
r14768: Fix potential null deref coverity bugs #255, #256.
Jeremy. (This used to be commit a40c7a0cd888dcee3cac1a41602863f54c51ef17)
Diffstat (limited to 'source3')
-rw-r--r--source3/registry/reg_objects.c42
1 files changed, 25 insertions, 17 deletions
diff --git a/source3/registry/reg_objects.c b/source3/registry/reg_objects.c
index 71c2e206c7..33c2660331 100644
--- a/source3/registry/reg_objects.c
+++ b/source3/registry/reg_objects.c
@@ -270,8 +270,6 @@ BOOL regval_ctr_key_exists( REGVAL_CTR *ctr, const char *value )
int regval_ctr_addvalue( REGVAL_CTR *ctr, const char *name, uint16 type,
const char *data_p, size_t size )
{
- REGISTRY_VALUE **ppreg;
-
if ( !name )
return ctr->num_values;
@@ -281,17 +279,24 @@ int regval_ctr_addvalue( REGVAL_CTR *ctr, const char *name, uint16 type,
/* allocate a slot in the array of pointers */
- if ( ctr->num_values == 0 )
+ if ( ctr->num_values == 0 ) {
ctr->values = TALLOC_P( ctr, REGISTRY_VALUE *);
- else {
- ppreg = TALLOC_REALLOC_ARRAY( ctr, ctr->values, REGISTRY_VALUE *, ctr->num_values+1 );
- if ( ppreg )
- ctr->values = ppreg;
+ } else {
+ ctr->values = TALLOC_REALLOC_ARRAY( ctr, ctr->values, REGISTRY_VALUE *, ctr->num_values+1 );
+ }
+
+ if (!ctr->values) {
+ ctr->num_values = 0;
+ return 0;
}
/* allocate a new value and store the pointer in the arrya */
ctr->values[ctr->num_values] = TALLOC_P( ctr, REGISTRY_VALUE);
+ if (!ctr->values[ctr->num_values]) {
+ ctr->num_values = 0;
+ return 0;
+ }
/* init the value */
@@ -310,23 +315,27 @@ int regval_ctr_addvalue( REGVAL_CTR *ctr, const char *name, uint16 type,
int regval_ctr_copyvalue( REGVAL_CTR *ctr, REGISTRY_VALUE *val )
{
- REGISTRY_VALUE **ppreg;
-
- if ( val )
- {
+ if ( val ) {
/* allocate a slot in the array of pointers */
- if ( ctr->num_values == 0 )
+ if ( ctr->num_values == 0 ) {
ctr->values = TALLOC_P( ctr, REGISTRY_VALUE *);
- else {
- ppreg = TALLOC_REALLOC_ARRAY( ctr, ctr->values, REGISTRY_VALUE *, ctr->num_values+1 );
- if ( ppreg )
- ctr->values = ppreg;
+ } else {
+ ctr->values = TALLOC_REALLOC_ARRAY( ctr, ctr->values, REGISTRY_VALUE *, ctr->num_values+1 );
+ }
+
+ if (!ctr->values) {
+ ctr->num_values = 0;
+ return 0;
}
/* allocate a new value and store the pointer in the arrya */
ctr->values[ctr->num_values] = TALLOC_P( ctr, REGISTRY_VALUE);
+ if (!ctr->values[ctr->num_values]) {
+ ctr->num_values = 0;
+ return 0;
+ }
/* init the value */
@@ -411,4 +420,3 @@ char* regval_sz( REGISTRY_VALUE *val )
return data;
}
-