Merged changes from 1.1 branch.

This commit is contained in:
Scott Ehlert
2008-12-05 15:57:49 -06:00
9 changed files with 177 additions and 39 deletions
+20 -2
View File
@@ -802,11 +802,29 @@ static cell_t sm_ReadFileString(IPluginContext *pContext, const cell_t *params)
char *buffer;
pContext->LocalToString(params[2], &buffer);
if (params[4] != -1)
{
if (size_t(params[4]) > size_t(params[3]))
{
return pContext->ThrowNativeError("read_count (%u) is greater than buffer size (%u)",
params[4],
params[3]);
}
num_read = (cell_t)fread(buffer, 1, params[4], pFile);
if (num_read != params[4] && ferror(pFile))
{
return -1;
}
return num_read;
}
char val;
while (1)
{
/* If we're in stop mode, break as soon as the buffer is full. */
if (params[4] && (params[3] == 0 || num_read >= params[3] - 1))
if (params[3] == 0 || num_read >= params[3] - 1)
{
break;
}