瀏覽代碼

regcomp: propagate allocation failures

The error code of an allocating function was not checked in tre_add_tag.
Szabolcs Nagy 9 年之前
父節點
當前提交
4260dfe1ec
共有 1 個文件被更改,包括 2 次插入1 次删除
  1. 2 1
      src/regex/regcomp.c

+ 2 - 1
src/regex/regcomp.c

@@ -1584,7 +1584,8 @@ tre_add_tags(tre_mem_t mem, tre_stack_t *stack, tre_ast_node_t *tree,
 		  {
 		    status = tre_add_tag_right(mem, left, tag_left);
 		    tnfa->tag_directions[tag_left] = TRE_TAG_MAXIMIZE;
-		    status = tre_add_tag_right(mem, right, tag_right);
+		    if (status == REG_OK)
+		      status = tre_add_tag_right(mem, right, tag_right);
 		    tnfa->tag_directions[tag_right] = TRE_TAG_MAXIMIZE;
 		  }
 		num_tags += 2;