在vs2017上运行没有问题,在学校的oj上(gcc编译器)发生段错误,不知道错误点在哪里,求点明

在vs2017上运行没有问题,在学校的oj上(gcc编译器)发生段错误,下面的代码是为了解决那个Biggest Number那个题目。小白一枚,实在找不到错误点,望大佬点明。

#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<time.h>
#include<string.h>
char temp[40];
int high, wide;
void DFS(char all[][15],int x,int y,char number[],int len)
{
    number[len] = all[x][y];
    all[x][y] -= 10;
    if (x + 1 < high && all[x + 1][y] != '#'&&all[x + 1][y] > '0')
    {
        DFS(all, x + 1, y, number, len+1);
        all[x + 1][y] += 10;
    }
    if (x - 1 >= 0 && all[x - 1][y] != '#'&&all[x - 1][y] > '0')
    {
        DFS(all, x - 1, y, number, len+1);
        all[x - 1][y] += 10;
    }
    if (y + 1 < wide && all[x][y + 1] != '#'&&all[x][y + 1]>'0')
    {
        DFS(all, x, y + 1, number, len+1);
        all[x][y + 1] += 10;
    }
    if (y - 1 >= 0 && all[x][y - 1] != '#'&&all[x][y - 1] > '0')
    {
        DFS(all, x, y - 1, number, len+1);
        all[x][y - 1] += 10;
    }
    if (strlen(temp) == strlen(number))
    {
        if (strcmp(number, temp) > 0)
            strcpy(temp, number);
        number[len] = '\0';
    }
    else if (strlen(temp) < strlen(number))
    {
        strcpy(temp, number);
        number[len] = '\0';
    }
    else
        number[len] = '\0';
}
int main()
{
    char all[15][15];
    char number[40];
    for (int i = 0; i < 25; i++)
    {

        memset(all, 0, 225);
        memset(temp, 0, 40);
        scanf("%d %d", &high, &wide);
        if (high == 0 && wide == 0)
            break;
        getchar();
        getchar();
        for (int i = 0; i < high; i++)
        {
            for (int j = 0; j < wide; j++)
                all[i][j] = getchar();
            getchar();
        }
        for (int i = 0; i < high; i++)
            for (int j = 0; j < wide; j++)
                if (all[i][j] != '#')
                {
                    memset(number, 0, 40);
                    int len = 0;
                    DFS(all, i, j, number, len);
                    all[i][j] += 10;
                }
        printf("%s \n", temp);
    }
    return 0;
}

应该是数组越界了

    if (x + 1 < high && all[x + 1][y] != '#'&&all[x + 1][y] > '0')
    {
        DFS(all, x + 1, y, number, len+1);
        all[x + 1][y] += 10;
    }
这个判断里面没有判断y是否越界
应该是
if(x+1 < hight && y < wide && ....){.....}
其他三个if也一样。


还有第一条语句
number[len]=all[x][y];
执行这条语句前应该先判断x、y是否越界。