Advertisement
snakemelon

1380. 矩阵中的幸运数 ERROR

Jan 25th, 2021
156
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. int* luckyNumbers (int** matrix, int matrixSize, int* matrixColSize, int* returnSize){
  2.     //int * ret = malloc(matrixSize*sizeof(int))
  3.     int *ret = (int*)malloc(sizeof(int) * matrixSize);
  4.     int min[matrixSize],max[*matrixColSize];
  5.     int mini,maxim,count=0,i,j;
  6.     for(i=0;i<matrixSize;i++){
  7.         mini = matrix[i][0];
  8.         for(j=0;j<matrixColSize;j++){
  9.             if(matrix[i][j]<mini) mini = matrix[i][j];
  10.         }
  11.         min[count++]=mini;
  12.         printf("mini=%d\n",mini);
  13.     }
  14.     *returnSize = matrixSize;
  15.     return ret;
  16. }
  17.  
  18. Error Information:
  19. =================================================================
  20. ==42==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x60200000003c at pc 0x5624fafe94aa bp 0x7ffc8d3a2dd0 sp 0x7ffc8d3a2dc0
  21. READ of size 4 at 0x60200000003c thread T0
  22.     #2 0x7f7d642ab0b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b2)
  23. 0x60200000003c is located 0 bytes to the right of 12-byte region [0x602000000030,0x60200000003c)
  24. allocated by thread T0 here:
  25.     #0 0x7f7d64ef0bc8 in malloc (/lib/x86_64-linux-gnu/libasan.so.5+0x10dbc8)
  26.     #4 0x7f7d642ab0b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b2)
  27. Shadow bytes around the buggy address:
  28.   0x0c047fff7fb0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  29.   0x0c047fff7fc0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  30.   0x0c047fff7fd0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  31.   0x0c047fff7fe0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  32.   0x0c047fff7ff0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  33. =>0x0c047fff8000: fa fa 00 04 fa fa 00[04]fa fa 00 04 fa fa 00 04
  34.   0x0c047fff8010: fa fa 00 04 fa fa fa fa fa fa fa fa fa fa fa fa
  35.   0x0c047fff8020: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  36.   0x0c047fff8030: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  37.   0x0c047fff8040: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  38.   0x0c047fff8050: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  39. Shadow byte legend (one shadow byte represents 8 application bytes):
  40.   Addressable:           00
  41.   Partially addressable: 01 02 03 04 05 06 07
  42.   Heap left redzone:       fa
  43.   Freed heap region:       fd
  44.   Stack left redzone:      f1
  45.   Stack mid redzone:       f2
  46.   Stack right redzone:     f3
  47.   Stack after return:      f5
  48.   Stack use after scope:   f8
  49.   Global redzone:          f9
  50.   Global init order:       f6
  51.   Poisoned by user:        f7
  52.   Container overflow:      fc
  53.   Array cookie:            ac
  54.   Intra object redzone:    bb
  55.   ASan internal:           fe
  56.   Left alloca redzone:     ca
  57.   Right alloca redzone:    cb
  58.   Shadow gap:              cc
  59. ==42==ABORTING
  60.  
Advertisement
RAW Paste Data Copied
Advertisement