WordPress.org

Make WordPress Core

Ticket #25643: 25643.patch

File 25643.patch, 1.1 KB (added by betzster, 8 years ago)

Fix the off by 1 error in the upload size unit calculation

  • wp-admin/includes/media.php

     
    15151515        $upload_size_unit = $max_upload_size = wp_max_upload_size();
    15161516        $sizes = array( 'KB', 'MB', 'GB' );
    15171517
    1518         for ( $u = -1; $upload_size_unit > 1024 && $u < count( $sizes ) - 1; $u++ ) {
     1518        for ( $u = -1; $upload_size_unit >= 1024 && $u < count( $sizes ) - 1; $u++ ) {
    15191519                $upload_size_unit /= 1024;
    15201520        }
    15211521
  • wp-includes/media-template.php

     
    7676                                $upload_size_unit = $max_upload_size = wp_max_upload_size();
    7777                                $byte_sizes = array( 'KB', 'MB', 'GB' );
    7878
    79                                 for ( $u = -1; $upload_size_unit > 1024 && $u < count( $byte_sizes ) - 1; $u++ ) {
     79                                for ( $u = -1; $upload_size_unit >= 1024 && $u < count( $byte_sizes ) - 1; $u++ ) {
    8080                                        $upload_size_unit /= 1024;
    8181                                }
    8282