fixing: strdup() needed
authorVolker Birk <vb@pep-project.org>
Wed, 13 Jul 2016 09:08:19 +0200
changeset 857349cbf352179
parent 855 27364c55fbaa
child 858 043a39b5e301
child 859 a3e8f082fc8a
fixing: strdup() needed
src/message_api.c
     1.1 --- a/src/message_api.c	Tue Jul 12 20:24:58 2016 +0200
     1.2 +++ b/src/message_api.c	Wed Jul 13 09:08:19 2016 +0200
     1.3 @@ -87,8 +87,16 @@
     1.4      assert(shortmsg);
     1.5      assert(strcmp(shortmsg, "pEp") != 0);
     1.6  
     1.7 -    if (!shortmsg || strcmp(shortmsg, "pEp") == 0)
     1.8 -        return longmsg;
     1.9 +    if (!shortmsg || strcmp(shortmsg, "pEp") == 0) {
    1.10 +        if (!longmsg) {
    1.11 +            return NULL;
    1.12 +        }
    1.13 +        else {
    1.14 +            char *result = strdup(longmsg);
    1.15 +            assert(result);
    1.16 +            return result;
    1.17 +        }
    1.18 +    }
    1.19          
    1.20      if (longmsg == NULL)
    1.21          longmsg = "";