The application discloses a method for detecting memory access overflow and a device for detecting memory access overflow. The method comprises the following steps of preprocessing source codes and analyzing a lexical structure, a grammatical structure and a semantic structure, and generating a control flow graph, a data dependence graph and an abstract syntax tree; establishing various detection models to different detection scenes, analyzing the control flow graph, the data dependence graph and the abstract syntax tree according to the various detection models, performing expression iteration, traversing state space, and outputting detection results; according to detection results, judging whether access overflow is present in source codes, and performing feedback output to detected memory access overflow. Therefore, the various detection models are defined by reviewing the control flow graph of the source codes, the data dependence graph and the abstract syntax tree, and expression iteration and state machine analysis are realized, the memory access overflow in the source codes can be fully excavated, the space and time cost for traversing the state space can be reduced, and underreporting and misinformation of the memory access overflow are reduced.