From: Jérémie Astor Date: Mon, 9 Dec 2019 21:20:54 +0000 (+0100) Subject: :art: prevent did_you_mean from overflow X-Git-Tag: nightly~1997 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=105e5754b360d470a3da2cded6442d30c486b3cb;p=gwion.git :art: prevent did_you_mean from overflow --- diff --git a/include/env/nspc.h b/include/env/nspc.h index 19c1eb8c..c0e3546a 100644 --- a/include/env/nspc.h +++ b/include/env/nspc.h @@ -67,6 +67,11 @@ describe_nspc_func(Func, func) ANN void did_you_mean_nspc(const Nspc, const char*); ANN void did_you_mean_type(const Type, const char*); + +#define DID_YOU_MEAN_LIMIT 128 +#define did_you_mean_nspc(a, b) if(strlen(b) < DID_YOU_MEAN_LIMIT) did_you_mean_nspc(a,b); +#define did_you_mean_type(a, b) if(strlen(b) < DID_YOU_MEAN_LIMIT) did_you_mean_type(a,b); + ANN static inline void nspc_allocdata(MemPool mp, const Nspc nspc) { if(nspc->info->class_data_size) // nspc->info->class_data = (m_bit*)xcalloc(1, nspc->info->class_data_size); diff --git a/src/parse/did_you_mean.c b/src/parse/did_you_mean.c index 83e81bbb..a9ae6956 100644 --- a/src/parse/did_you_mean.c +++ b/src/parse/did_you_mean.c @@ -43,6 +43,7 @@ ANN static void ressembles(const Vector v, const Nspc nspc, const char* name) { } } +#undef did_you_mean_nspc ANN void did_you_mean_nspc(Nspc nspc, const char* name) { struct Vector_ v; vector_init(&v); @@ -53,6 +54,7 @@ ANN void did_you_mean_nspc(Nspc nspc, const char* name) { vector_release(&v); } +#undef did_you_mean_type ANN void did_you_mean_type(Type type, const char* name) { Type t = type; struct Vector_ v;