[vlc-devel] [PATCH] ConfigLoadString loses the last character of strings
Mario Speiß
1034-135 at online.de
Fri Jan 18 23:52:36 CET 2013
ConfigLoadString allocates memory for 'size' bytes and copys a NULL terminated
string to this buffer.
ConfigSaveString instead expects the buffer to be NULL terminated but:
- the 'size' saved to the cache is the char count
- the string is written without terminating NULL.
So obviously ConfigLoadString does not match the behaviour of ConfigSaveString.
It seems to me that the cached module configuration is not working at all due
to comparing the module file names within CacheFind - this should never have
found a match.
I think this would need some more testing.
Regards,
Mario
---
src/modules/cache.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/modules/cache.c b/src/modules/cache.c
index bd9b32d..9d83632 100644
--- a/src/modules/cache.c
+++ b/src/modules/cache.c
@@ -96,7 +96,7 @@ error:
if (size > 0)
{
- psz = malloc (size);
+ psz = malloc (size+1);
if (unlikely(psz == NULL))
goto error;
if (fread (psz, 1, size, file) != size)
@@ -104,7 +104,7 @@ error:
free (psz);
goto error;
}
- psz[size - 1] = '\0';
+ psz[size] = '\0';
}
*p = psz;
return 0;
--
1.7.5.4
More information about the vlc-devel
mailing list