summaryrefslogtreecommitdiff
path: root/source3/param/loadparm.c
diff options
context:
space:
mode:
Diffstat (limited to 'source3/param/loadparm.c')
-rw-r--r--source3/param/loadparm.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index cb7f9f35c3..b004265261 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -1782,16 +1782,25 @@ static int add_a_service(service * pservice, char *name)
/* if not, then create one */
if (i == iNumServices)
{
- ServicePtrs =
- (service **) Realloc(ServicePtrs,
- sizeof(service *) *
- num_to_alloc);
- if (ServicePtrs)
+ service **tsp;
+
+ tsp = (service **) Realloc(ServicePtrs,
+ sizeof(service *) *
+ num_to_alloc);
+
+ if (!tsp) {
+ DEBUG(0,("add_a_service: failed to enlarge ServicePtrs!\n"));
+ return (-1);
+ }
+ else {
+ ServicePtrs = tsp;
ServicePtrs[iNumServices] =
(service *) malloc(sizeof(service));
-
- if (!ServicePtrs || !ServicePtrs[iNumServices])
+ }
+ if (!ServicePtrs[iNumServices]) {
+ DEBUG(0,("add_a_service: out of memory!\n"));
return (-1);
+ }
iNumServices++;
}