]> Nishi Git Mirror - gwion.git/commitdiff
:art: prevent did_you_mean from overflow
authorJérémie Astor <astor.jeremie@wanadoo.fr>
Mon, 9 Dec 2019 21:20:54 +0000 (22:20 +0100)
committerJérémie Astor <astor.jeremie@wanadoo.fr>
Mon, 9 Dec 2019 21:20:54 +0000 (22:20 +0100)
include/env/nspc.h
src/parse/did_you_mean.c

index 19c1eb8c065af1449603b39fd912133e98132cd5..c0e3546a1c891a215289653564e86a73cdca21c4 100644 (file)
@@ -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);
index 83e81bbba581fd3a4530cbb02a2854d64f704843..a9ae69561394e933527eeb9f72845c2869865735 100644 (file)
@@ -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;