tidied up advtopic code
[srvx.git] / src / chanserv.c
index d50c9147fbe56909b65f776179f763e99bb2ca8d..4e41784b0aa289a7506251bd28bb6667740dcf5a 100644 (file)
@@ -4446,7 +4446,6 @@ static CHANSERV_FUNC(cmd_topic)
                             new_topic[dpos++] = *ptr; //is % again
                             break;
                         }
-                        ptr--;
                         advtopic_index--; //no zero base
                         if(!cData->advtopic[advtopic_index])
                             break; //just leave it empty
@@ -4458,11 +4457,12 @@ static CHANSERV_FUNC(cmd_topic)
                         break;
                     case '\\': 
                         ptr++; /* and fall through */
+                        if(!*ptr) break;
                     default:
                         new_topic[dpos++] = *ptr;
+                        ptr++;
                         break;
                     }
-                    ptr++;
                 }
             } else {
                 while((tchar = topic_mask[pos++]) && (dpos <= TOPICLEN))