[vlc-commits] ConfigLoadString loses the last character of strings
Mario Speiß
git at videolan.org
Sat Jan 19 09:45:34 CET 2013
vlc | branch: master | Mario Speiß <1034-135 at online.de> | Fri Jan 18 23:52:36 2013 +0100| [a63f061bc42d7c472ba72a5e3feacc0751d4d072] | committer: Rémi Denis-Courmont
ConfigLoadString loses the last character of strings
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
Signed-off-by: Rémi Denis-Courmont <remi at remlab.net>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=a63f061bc42d7c472ba72a5e3feacc0751d4d072
---
src/modules/cache.c | 4 ++--
1 file 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;
More information about the vlc-commits
mailing list