diff options
-rw-r--r-- | src/Quest.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/Quest.cpp b/src/Quest.cpp index 8aea006..2eed1ae 100644 --- a/src/Quest.cpp +++ b/src/Quest.cpp @@ -14,9 +14,21 @@ const Quest QuestList[TOTAL_QUESTS]={ };
+// Trust nobody
+#define STRLEN_MIN 16
+
+unsigned int safe_strlen(const char *s){
+ unsigned int size=0;
+ while(s[size])size++;
+ if(size<STRLEN_MIN)return STRLEN_MIN;
+ else return size;
+}
+
Quest::Quest(const char *t,const char *d,struct item_t r){
- strcpy((title=(char *)malloc(strlen(t))),t);
- strcpy((desc =(char *)malloc(strlen(d))),d);
+ title=(char *)calloc(safe_strlen(t),sizeof(char));
+ desc=(char *)calloc(safe_strlen(d),sizeof(char));
+ strcpy(title,t);
+ strcpy(desc,d);
memcpy(&reward,&r,sizeof(struct item_t));
}
|