diff options
author | Matt Kraai <kraai@debian.org> | 2000-09-13 02:46:14 +0000 |
---|---|---|
committer | Matt Kraai <kraai@debian.org> | 2000-09-13 02:46:14 +0000 |
commit | 322ae93a5e0b78b65831f9fd87fd456eb84d21a1 (patch) | |
tree | 5b967e1d873ff6eff8296bf9fda73825f0c55884 /utility.c | |
parent | b89075298edf0a471b9046b1f3c8a936e18ead20 (diff) | |
download | busybox-w32-322ae93a5e0b78b65831f9fd87fd456eb84d21a1.tar.gz busybox-w32-322ae93a5e0b78b65831f9fd87fd456eb84d21a1.tar.bz2 busybox-w32-322ae93a5e0b78b65831f9fd87fd456eb84d21a1.zip |
Fix calls to {m,c,re}alloc so that they use x{m,c,re}alloc instead of
segfaulting or handling errors the same way themselves.
Diffstat (limited to 'utility.c')
-rw-r--r-- | utility.c | 12 |
1 files changed, 4 insertions, 8 deletions
@@ -1290,7 +1290,7 @@ extern pid_t* findPidByName( char* pidName) | |||
1290 | * some new processes start up while we wait. The kernel will | 1290 | * some new processes start up while we wait. The kernel will |
1291 | * just ignore any extras if we give it too many, and will trunc. | 1291 | * just ignore any extras if we give it too many, and will trunc. |
1292 | * the list if we give it too few. */ | 1292 | * the list if we give it too few. */ |
1293 | pid_array = (pid_t*) calloc( num_pids+10, sizeof(pid_t)); | 1293 | pid_array = (pid_t*) xcalloc( num_pids+10, sizeof(pid_t)); |
1294 | pid_array[0] = num_pids+10; | 1294 | pid_array[0] = num_pids+10; |
1295 | 1295 | ||
1296 | /* Now grab the pid list */ | 1296 | /* Now grab the pid list */ |
@@ -1316,9 +1316,7 @@ extern pid_t* findPidByName( char* pidName) | |||
1316 | 1316 | ||
1317 | if ((strstr(info.command_line, pidName) != NULL) | 1317 | if ((strstr(info.command_line, pidName) != NULL) |
1318 | && (strlen(pidName) == strlen(info.command_line))) { | 1318 | && (strlen(pidName) == strlen(info.command_line))) { |
1319 | pidList=realloc( pidList, sizeof(pid_t) * (j+2)); | 1319 | pidList=xrealloc( pidList, sizeof(pid_t) * (j+2)); |
1320 | if (pidList==NULL) | ||
1321 | fatalError(memory_exhausted); | ||
1322 | pidList[j++]=info.pid; | 1320 | pidList[j++]=info.pid; |
1323 | } | 1321 | } |
1324 | } | 1322 | } |
@@ -1389,9 +1387,7 @@ extern pid_t* findPidByName( char* pidName) | |||
1389 | 1387 | ||
1390 | if ((strstr(p, pidName) != NULL) | 1388 | if ((strstr(p, pidName) != NULL) |
1391 | && (strlen(pidName) == strlen(p))) { | 1389 | && (strlen(pidName) == strlen(p))) { |
1392 | pidList=realloc( pidList, sizeof(pid_t) * (i+2)); | 1390 | pidList=xrealloc( pidList, sizeof(pid_t) * (i+2)); |
1393 | if (pidList==NULL) | ||
1394 | fatalError(memory_exhausted); | ||
1395 | pidList[i++]=strtol(next->d_name, NULL, 0); | 1391 | pidList[i++]=strtol(next->d_name, NULL, 0); |
1396 | } | 1392 | } |
1397 | } | 1393 | } |
@@ -1624,7 +1620,7 @@ extern char *get_line_from_file(FILE *file) | |||
1624 | break; | 1620 | break; |
1625 | /* grow the line buffer as necessary */ | 1621 | /* grow the line buffer as necessary */ |
1626 | if (idx > linebufsz-2) | 1622 | if (idx > linebufsz-2) |
1627 | linebuf = realloc(linebuf, linebufsz += GROWBY); | 1623 | linebuf = xrealloc(linebuf, linebufsz += GROWBY); |
1628 | linebuf[idx++] = (char)ch; | 1624 | linebuf[idx++] = (char)ch; |
1629 | if ((char)ch == '\n') | 1625 | if ((char)ch == '\n') |
1630 | break; | 1626 | break; |