Skip to content

Commit

Permalink
tapestat: prevent reallocing to 0 bytes
Browse files Browse the repository at this point in the history
Ensure that realloc is not using 0 as new size in
tape_check_tapes_and_realloc() function.
  • Loading branch information
Peter Schiffer committed Jun 1, 2016
1 parent 345b006 commit 24d35c4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tapestat.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ void tape_check_tapes_and_realloc(void)
/* Count again number of tapes */
new_max_tape_drives = get_max_tape_drives();

if (new_max_tape_drives > max_tape_drives) {
if (new_max_tape_drives > max_tape_drives && new_max_tape_drives > 0) {
/* New tapes found: Realloc structures */
struct tape_stats *tape_old_stats_t = (struct tape_stats *)
realloc(tape_old_stats, sizeof(struct tape_stats) * new_max_tape_drives);
Expand Down

0 comments on commit 24d35c4

Please sign in to comment.