Added some parenthesis and a cast to control order of operations. (#32640)
authorNathan Ricci <naricc@microsoft.com>
Fri, 21 Feb 2020 18:50:55 +0000 (13:50 -0500)
committerGitHub <noreply@github.com>
Fri, 21 Feb 2020 18:50:55 +0000 (13:50 -0500)
Fix intermittent negative values from GetTotalBytesAllocated.

src/mono/mono/metadata/sgen-mono.c

index 038f435..d9baf86 100644 (file)
@@ -2639,7 +2639,7 @@ mono_gc_get_allocated_bytes_for_current_thread (void)
        info = mono_thread_info_current ();
 
        /*There are some more allocated bytes in the current tlab that have not been recorded yet */
-       return info->total_bytes_allocated + info->tlab_next - info->tlab_start;
+       return info->total_bytes_allocated + (ptrdiff_t)(info->tlab_next - info->tlab_start);
 }
 
 guint64