upnpdescgen.c: error message when memory alloc fails

This commit is contained in:
Thomas Bernard 2020-06-02 00:24:15 +02:00
parent 7b9489fb84
commit c0ea7926c0
No known key found for this signature in database
GPG Key ID: 0FF11B67A5C0863C
1 changed files with 5 additions and 0 deletions

View File

@ -9,6 +9,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <syslog.h>
#include "config.h"
#ifdef ENABLE_EVENTS
@ -816,7 +817,10 @@ strcat_str(char * str, int * len, int * tmplen, const char * s2)
newlen = *tmplen + s2len + 1;
p = (char *)realloc(str, newlen);
if(p == NULL) /* handle a failure of realloc() */
{
syslog(LOG_ERR, "strcat_str: Failed to realloc %d bytes", newlen);
return str;
}
str = p;
*tmplen = newlen;
}
@ -840,6 +844,7 @@ strcat_char(char * str, int * len, int * tmplen, char c)
p = (char *)realloc(str, *tmplen);
if(p == NULL) /* handle a failure of realloc() */
{
syslog(LOG_ERR, "strcat_char: Failed to realloc %d bytes", *tmplen);
*tmplen -= 256;
return str;
}